Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (checkFileExists('config.yml')) {
// config.yml exists, load it
log(colors.bold(colors.cyan('config.yml')), 'exists, loading', colors.bold(colors.cyan('config.yml')));
let ymlFile = fs.readFileSync('config.yml', 'utf8');
return yaml.load(ymlFile);
} else if(checkFileExists('config-default.yml')) {
// config-default.yml exists, load it
log(colors.bold(colors.cyan('config.yml')), 'does not exist, loading', colors.bold(colors.cyan('config-default.yml')));
let ymlFile = fs.readFileSync('config-default.yml', 'utf8');
return yaml.load(ymlFile);
} else {
// Exit if config.yml & config-default.yml do not exist
log('Exiting process, no config file exists.');
log('Error Code:', err.code);
process.exit(1);
}
}
}
const commandTemplate = Handlebars.compile(await fs.readFile(path.resolve(rootFolder, 'commands-yml', 'api-template.md'), 'utf8'), {noEscape: true, strict: true});
async function writeIndex (index, commands, indexPath) {
log(`Creating API index '${index}'`);
const commandMarkdown = commandTemplate({
commands,
path: indexPath,
});
await fs.writeFile(index, commandMarkdown, 'utf8');
}
const apiIndex = path.resolve(rootFolder, 'docs', 'en', 'about-appium', 'api.md');
await writeIndex(apiIndex, commands);
log(`Done writing main API index`);
async function writeIndividualIndexes (command) {
if (!util.hasValue(command.commands)) {
// this is a leaf, so end
return;
}
// write this node
const relPath = command.path.startsWith(path.sep) ? command.path.substring(1) : command.path;
const index = path.resolve(rootFolder, relPath, 'README.md');
await writeIndex(index, command.commands, command.path);
// go through all the sub-commands
for (const el of command.commands) {
await writeIndividualIndexes(el);
}
.pipe(sass({ includePaths: ['./app'] }).on('error', function (error) {
log(c.red('Error (' + error.plugin + '): ' + error.message))
this.emit('end')
}))
.pipe(gulpif(args.production, cleanCSS()))
mainWindow.webContents.on("did-finish-load", () => {
log("Finished loading")
if (!mainWindow) return
mainWindow.show()
mainWindow.focus()
if (isDev) {
log("Launching dev tools")
mainWindow.webContents.openDevTools()
}
if (inputFiles.length > 0) {
if (inputFiles.length > 1) {
console.error("Multiple input files are currently not supported")
}
log("Visiting file")
mainWindow.webContents.send("fno:visit-file", inputFiles[0])
}
const runCommand = (
command: string,
options: Required,
file: Vinyl | null
): Promise => {
const context = { file, ...options.templateData }
command = template(command)(context)
if (options.verbose) {
fancyLog(`${PLUGIN_NAME}:`, chalk.cyan(command))
}
const child = spawn(command, {
env: options.env,
cwd: template(options.cwd)(context),
shell: options.shell,
stdio: options.quiet ? 'ignore' : 'inherit'
})
return new Promise((resolve, reject) => {
child.on('exit', code => {
if (code === 0 || options.ignoreErrors) {
return resolve()
}
const context = {
.on('change', path => log('File ' + colors.bold(colors.magenta(path)) + ' changed.'))
.on('unlink', path => log('File ' + colors.bold(colors.magenta(path)) + ' was removed.'));
gulp.src( [ '_inc/build/static*' ] )
.pipe( tap( function( file ) {
fs.unlinkSync( file.path );
} ) )
.on( 'end', function() {
fs.writeFile( __dirname + '/_inc/build/static.html', window.staticHtml );
fs.writeFile( __dirname + '/_inc/build/static-noscript-notice.html', window.noscriptNotice );
fs.writeFile( __dirname + '/_inc/build/static-version-notice.html', window.versionNotice );
fs.writeFile( __dirname + '/_inc/build/static-ie-notice.html', window.ieNotice );
if ( done ) {
done();
}
} );
} catch ( error ) {
log( colors.yellow(
'Warning: gulp was unable to update static HTML files.\n\n' +
'If this is happening during watch, this warning is OK to dismiss: sometimes webpack fires watch handlers when source code is not yet built.'
) );
}
} );
}
.on( 'end', function() {
log( 'Your other JS is now uglified!' );
} );
.on( 'end', function() {
log( 'Your JS is now uglified!' );
} );
}
.on( 'end', function() {
log( success );
done();
} );
}