Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var error = cli.red.bold,
info = cli.cyan,
done = cli.green;
// Check
var nodeCheck = sh.which('node');
// Welcome Message
sh.echo(info('→ Initializing...'));
// Create
sh.echo(info('→ Creating Structure'));
sh.rm('-rf', ['./node_modules', './.git', '.gitignore', '.editorconfig', '.travis.yml', 'newproject.js', 'package.json', 'README.md', 'logo-bp.jpg']);
sh.mv('./init/templates/webapp/ng-app/*', './');
sh.rm('-rf', ['./init', './lib']);
// Setup
sh.echo(info('→ Setting up project'));
sh.cd('./src');
if (!nodeCheck) {
sh.echo(error('✖ This task requires NodeJS to run.'));
process.exit(1);
} else {
sh.exec('sudo npm install');
sh.exec('npm run build');
}
sh.echo(done('✔ All Done!'));
// log.transports.file.file = __dirname + '/log.txt';
log.transports.file.file = homeDir + '/Livepeer/log.txt';
// fs.createWriteStream options, must be set before first logging
log.transports.file.streamConfig = { flags: 'w' };
// set existed file stream
if (!fs.existsSync(homeDir+"/Livepeer/")) {
console.log("Making Logging Dir")
shell.mkdir('-p', homeDir+"/Livepeer/");
}
//Remove log file if it's too big
if (fs.existsSync(homeDir+"/Livepeer/log.txt")) {
var stats = fs.statSync(homeDir+"/Livepeer/log.txt")
if (stats.size > 10*1000*1000) {
shell.rm(homeDir+"/Livepeer/log.txt")
}
}
log.transports.file.stream = fs.createWriteStream(homeDir + '/Livepeer/log.txt', {'flags': 'a'});
log.transports.file.appName = 'LivepeerDesktop';
}
extractModules(extract) {
const ext = ['.js', '.bat', '.sh', '.cmd', ''];
if (extract.length > 0) {
if (this.$.utils.exists(this.$.env.paths.electronApp.extractedNodeModules)) {
shell.rm('-rf', this.$.env.paths.electronApp.extractedNodeModules);
}
fs.mkdirSync(this.$.env.paths.electronApp.extractedNodeModules);
fs.mkdirSync(this.$.env.paths.electronApp.extractedNodeModulesBin);
extract.forEach((module) => {
fs.renameSync(
path.join(this.$.env.paths.electronApp.appRoot, 'node_modules', module),
path.join(this.$.env.paths.electronApp.extractedNodeModules, module),
);
// Move bins.
this.extractBin(module, ext);
});
return true;
}
return false;
function cleanUpOutputDirectory() {
if (rootDirectoryForCleanUp !== undefined) {
shell.rm('-rf', rootDirectoryForCleanUp);
return;
}
if (fileStats.doesDownloadDirectory) {
shell.rm('-rf', localRootDirectory);
} else {
// Mainly for remove .zip file, when download a whole repo
shell.rm('-f', localRootDirectory + currentDownloadingFile);
}
}
// Messages
var error = cli.red.bold,
info = cli.cyan,
done = cli.green;
// Check
var nodeCheck = sh.which('node');
// Scaffolding
// ----------------------------------
sh.echo(info('→ Initializing...'));
sh.rm('-rf', ['./node_modules', './.git', '.gitignore', '.editorconfig', '.travis.yml', 'newproject.js', 'package.json', 'README.md', 'logo-bp.jpg']);
sh.echo(info('→ Creating Structure...'));
sh.mv('./init/templates/general/web-bs/*', './');
sh.rm('-rf', ['./init']);
sh.echo(done('✔ Created!'));
// Setup
// ----------------------------------
sh.echo(info('→ Setting up project...'));
// Move on to "./src" folder
sh.cd('./src');
// Check if NodeJS exists and install dependencies
function regenApiImplNativeFixture() {
logHeader('Regenerating Native API Implementation Fixture')
shell.rm('-rf', pathsToFixtures['api-impl-native'])
shell.exec(
`ern create-api-impl ${f.movieApiPkgName} -p ${
f.movieApiImplPkgName
} --skipNpmCheck --nativeOnly --outputDirectory ${
pathsToFixtures['api-impl-native']
} --force`
)
}
function clearPath() {
if (!shell.test('-d', env.sourceFolder)) {
return;
}
shell.rm('-rf', env.sourceFolder);
}
packageNames.forEach(pkgName => {
const outputPath = getOutputPath(pkgName);
if (test('-d', outputPath)) {
chmod('-R', 'u+w', outputPath);
rm('-rf', outputPath);
}
});
}
for (const key in this._commands) {
const command = this._commands[key];
if (key === nameOrAlias || command.package.name === nameOrAlias) {
packagePath = command.package.path;
packageName = command.package.name;
break;
}
}
if (packageName || packagePath) {
if (!packagePath) {
packagePath = path.join(utils.homePath(), 'node_modules', packageName);
}
if (fs.existsSync(packagePath)) {
try {
shell.rm('-rf', packagePath);
logger.success(`Remove package \`${packageName}\` successful...`);
}
catch (e) {
logger.error(e);
}
}
}
else {
logger.error(`Cannot found the \`${nameOrAlias}\` as alias or package name, please check`);
}
}
function cleanupDef() {
rm(typingSource);
}
function copyFiles() {