Setup ESLint and Prettier and apply changes to sources #891

Merged
IGassmann merged 22 commits from issue/763 into master 2017-12-27 21:22:51 +01:00
Showing only changes of commit 3b26f06210 - Show all commits

View file

@ -1,20 +1,21 @@
const extract = require("i18n-extract");
const fs = require("fs");
const path = require("path");
const dir = `${__dirname}/../../static/locales`;
const path = `${dir}/en.json`;
const outputDir = `${__dirname}/../static/locales`;
const outputPath = `${outputDir}/en.json`;
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir);
}
fs.writeFile(path, "{}", "utf8", err => {
fs.writeFile(outputPath, "{}", "utf8", err => {
if (err) {
return console.log(err);
}
const enLocale = require(path);
const enLocale = require(outputPath);
const keys = extract.extractFromFiles(["js/**/*.{js,jsx}"], {
const keys = extract.extractFromFiles("src/**/*.{js,jsx}", {
marker: "__",
});
@ -22,7 +23,7 @@ fs.writeFile(path, "{}", "utf8", err => {
reports = reports.concat(extract.findMissing(enLocale, keys));
if (reports.length > 0) {
fs.readFile(path, "utf8", (err, data) => {
fs.readFile(outputPath, "utf8", (err, data) => {
if (err) {
console.log(err);
} else {
@ -36,7 +37,7 @@ fs.writeFile(path, "{}", "utf8", err => {
}
const json = JSON.stringify(localeObj, null, "\t"); // convert it back to json-string
fs.writeFile(path, json, "utf8", err => {
fs.writeFile(outputPath, json, "utf8", err => {
if (err) {
throw err;
}