@opensea/i18n-extract
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -48,2 +48,4 @@ #!/usr/bin/env node | ||
var extract_1 = require("./extract"); | ||
var path_1 = __importDefault(require("path")); | ||
var file_1 = require("./file"); | ||
var extract = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -58,7 +60,7 @@ var options, directory, out, spinner, files, translations; | ||
.requiredOption("-D, --directory <directory>", "Source directory to recursively extract i18n keys.") | ||
.requiredOption("-O, --out <out>", "Path to the locale file with extracted translations keys."); | ||
.requiredOption("-O, --out <out>", "Directory where to extract translations keys into."); | ||
options = commander_1.program.parse().opts(); | ||
directory = options.directory, out = options.out; | ||
spinner = (0, ora_1.default)("Processing files for translations...").start(); | ||
return [4 /*yield*/, (0, glob_1.glob)("".concat(directory, "/**/*"))]; | ||
return [4 /*yield*/, (0, glob_1.glob)("".concat(directory, "/**/*.{ts,tsx}"))]; | ||
case 1: | ||
@@ -69,5 +71,15 @@ files = _a.sent(); | ||
translations = _a.sent(); | ||
return [4 /*yield*/, promises_1.default.writeFile(out, JSON.stringify(translations, null, 2))]; | ||
return [4 /*yield*/, (0, file_1.fileExists)(out)]; | ||
case 3: | ||
if (!!(_a.sent())) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, promises_1.default.mkdir(out, { recursive: true })]; | ||
case 4: | ||
_a.sent(); | ||
_a.label = 5; | ||
case 5: return [4 /*yield*/, Promise.all(Object.keys(translations).map(function (namespace) { | ||
var outfile = path_1.default.join(out, "".concat(namespace, ".json")); | ||
return promises_1.default.writeFile(outfile, JSON.stringify(translations[namespace], null, 2)); | ||
}))]; | ||
case 6: | ||
_a.sent(); | ||
spinner.succeed("All translations created!"); | ||
@@ -74,0 +86,0 @@ return [2 /*return*/]; |
{ | ||
"name": "@opensea/i18n-extract", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Package for i18n key extractions", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
49860
24
418
4