@talend/i18n-scripts
Advanced tools
Comparing version 0.1.1 to 0.1.2
11
index.js
@@ -0,1 +1,2 @@ | ||
#!/usr/bin/env node | ||
/* eslint-disable global-require,no-console */ | ||
@@ -18,2 +19,10 @@ | ||
require(`./scripts/${command}`)(configuration); | ||
const scriptPath = path.join(__dirname, 'scripts', command || ''); | ||
if (!fs.existsSync(`${scriptPath}.js`)) { | ||
error(` | ||
The command provided has not been recognized | ||
"${command}" doesn't exist. | ||
`); | ||
} | ||
require(scriptPath)(configuration); |
{ | ||
"name": "@talend/i18n-scripts", | ||
"description": "Set of scripts to ease i18n workflow", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "Apache-2.0", | ||
@@ -23,2 +23,3 @@ "main": "index.js", | ||
"cross-spawn": "^6.0.4", | ||
"find": "^0.2.9", | ||
"form-data": "^2.3.3", | ||
@@ -25,0 +26,0 @@ "lodash.template": "^4.4.0", |
@@ -7,2 +7,3 @@ const fs = require('fs'); | ||
const Zip = require('adm-zip'); | ||
const find = require('find'); | ||
@@ -13,2 +14,24 @@ const error = require('../common/error'); | ||
/** | ||
* List the files under a given path | ||
* @param {String} path | ||
* @returns {Promise} | ||
*/ | ||
function listFiles(path) { | ||
return new Promise((resolve, reject) => { | ||
find.file(path, resolve) | ||
}); | ||
} | ||
/** | ||
* List the directories under a given path | ||
* @param {String} path | ||
* @returns {Promise} | ||
*/ | ||
function listDirs(path) { | ||
return new Promise((resolve, reject) => { | ||
find.dir(path, resolve) | ||
}); | ||
} | ||
function extractNpmYarn({ script, method, target }) { | ||
@@ -85,12 +108,8 @@ if (!script || !target) { | ||
function runTransform({ transform, target }) { | ||
async function runTransform({ transform, target }) { | ||
if (transform === 'flatten') { | ||
const filesChild = spawn.sync('find', [target, '-type', 'f']); | ||
if (filesChild.status !== 0) { | ||
error(filesChild.stderr.toString()); | ||
} | ||
filesChild.stdout | ||
.toString() | ||
.split('\n') | ||
.filter(filePath => filePath) | ||
const filesChild = await listFiles(target); | ||
filesChild | ||
.forEach(filePath => { | ||
@@ -101,9 +120,4 @@ const fileName = path.basename(filePath); | ||
const directoriesChild = spawn.sync('find', [target, '-type', 'd']); | ||
if (directoriesChild.status !== 0) { | ||
error(directoriesChild.stderr.toString()); | ||
} | ||
directoriesChild.stdout | ||
.toString() | ||
.split('\n') | ||
const directoriesChild = await listDirs(target); | ||
directoriesChild | ||
.filter(folderPath => folderPath && folderPath !== target) | ||
@@ -130,3 +144,3 @@ .forEach(folderPath => rimraf.sync(folderPath)); | ||
function runExtract({ extract }) { | ||
async function runExtract({ extract }) { | ||
const { method, target } = extract; | ||
@@ -154,3 +168,3 @@ rimraf.sync(target); | ||
runTransform(extract); | ||
await runTransform(extract); | ||
wrapWithVersion(extract); | ||
@@ -157,0 +171,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
120663
1072
4
13
+ Addedfind@^0.2.9
+ Addedfind@0.2.9(transitive)
+ Addedtraverse-chain@0.1.0(transitive)