@frontend-project-generator/utils
Advanced tools
Comparing version 0.0.9 to 0.0.10
'use strict'; | ||
const fs = require('fs'); | ||
function isObject(o) { | ||
return Object.prototype.toString.call(o) === '[object Object]'; | ||
return Object.prototype.toString.call(o) === '[object Object]'; | ||
} | ||
function spinnerStart(msg, spinnerString = '|/-\\') { | ||
const Spinner = require('cli-spinner').Spinner; | ||
const spinner = new Spinner(msg + ' %s'); | ||
spinner.setSpinnerString(spinnerString); | ||
spinner.start(); | ||
return spinner; | ||
} | ||
function sleep(timeout = 1000) { | ||
return new Promise(resolve => setTimeout(resolve, timeout)); | ||
} | ||
function exec(command, args, options) { | ||
const win32 = process.platform === 'win32'; | ||
const cmd = win32 ? 'cmd' : command; | ||
const cmdArgs = win32 ? ['/c'].concat(command, args) : args; | ||
return require('child_process').spawn(cmd, cmdArgs, options || {}); | ||
} | ||
function execAsync(command, args, options) { | ||
return new Promise((resolve, reject) => { | ||
const p = exec(command, args, options); | ||
p.on('error', e => { | ||
reject(e); | ||
}); | ||
p.on('exit', c => { | ||
resolve(c); | ||
}); | ||
}); | ||
} | ||
function readFile(path, options = {}) { | ||
if (fs.existsSync(path)) { | ||
const buffer = fs.readFileSync(path); | ||
if (buffer) { | ||
if (options.toJson) { | ||
return buffer.toJSON(); | ||
} else { | ||
return buffer.toString(); | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
function writeFile(path, data, { rewrite = true } = {}) { | ||
if (fs.existsSync(path)) { | ||
if (rewrite) { | ||
fs.writeFileSync(path, data); | ||
return true; | ||
} | ||
return false; | ||
} else { | ||
fs.writeFileSync(path, data); | ||
return true; | ||
} | ||
} | ||
module.exports = { | ||
isObject | ||
} | ||
isObject, | ||
spinnerStart, | ||
sleep, | ||
exec, | ||
execAsync, | ||
readFile, | ||
writeFile, | ||
}; |
{ | ||
"name": "@frontend-project-generator/utils", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "> TODO: description", | ||
@@ -9,2 +9,5 @@ "author": "381119117@qq.com <381119117@qq.com>", | ||
"main": "lib/utils.js", | ||
"dependencies": { | ||
"cli-spinner": "^0.2.10" | ||
}, | ||
"directories": { | ||
@@ -20,3 +23,3 @@ "lib": "lib", | ||
}, | ||
"gitHead": "c209f77ad15bd4c236409d4cc1d06882465ba8bd" | ||
"gitHead": "dc6b7f6c8a18ac22513206ec02ac5eb81f1ddc3f" | ||
} |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2223
66
1
2
+ Addedcli-spinner@^0.2.10
+ Addedcli-spinner@0.2.10(transitive)