fs.stat(filePath, function(err, stats) { if (stats === undefined) { var writeFile = fs.createWriteStream(filePath); readTemplate.on('data', function(chunk) { var newData = chunk.toString() .replace(/__Name__/g, fileName); writeFile.write(newData); writeFile.end(); }); readTemplate.on('end', function(error) { if (error) console.log(colors.red(error.toString())); }); importGen(fileType, filePath, inpm, directory, currentWDir); importDefaults(defaults, filePath, fileType, directory, currentWDir); generateTest(filePath, fileType, fileName, directory, currentWDir); generateCSS(fileName, fileType, currentWDir); console.log('Successfuly created ' + colors.yellow(fileName + '.js') + ' in ' + colors.yellow(filePath.toString())); } else { console.log(colors.yellow(fileName + '.js') + colors.red(' already exists in this project.')); } });
prompt.get(properties, function (err, result) { if(err) { onError(err); } // TODO: Run plugins to inject properties console.log(colors.yellow("Copying template...")); copyTemplate(templatePackagePath, workingDirectory); // Inject properties console.log(colors.yellow("Injecting values...")); properties.forEach(function (prop) { var value = result[prop.name]; replace({ regex: "{{" + prop.name + "}}", replacement: value, paths: [workingDirectory], recursive: true, silent: true, }); }); console.log(colors.green("Template creation successful")) });
exports.addKey = function(current, filepath, callback) { if (!filepath) { console.log(colors.yellow('No filepath given')); return; } // Turn relative paths into absolute paths if (!path.isAbsolute(filepath)){ filepath = path.join(process.cwd(), filepath); } // Check that path exists if (!fs.existsSync(filepath)) { console.log(colors.yellow('Filepath does not exist!')); return; } if (!fs.statSync(filepath).isFile()) { console.log(colors.yellow('Supplied key is not a file')); return; } if (!current.ssl) { current.ssl = {}; } current.ssl.key = filepath; callback(current); }
Object.keys(submodules).forEach(name => { const sub = subs[name]; const commit = sub.commit; const index = sub.index; const wd = sub.workdir; const SAME = RepoStatus.Submodule.COMMIT_RELATION.SAME; const newSha = submodules[name].commit.id().tostrS(); if (null !== wd) { // Check to see if there are new commits on both index and HEAD // of workdir. If this is the case, we cannot checkout the // submodule without changing its state. if (wd.relation !== SAME && index.relation !== SAME) { errors.push(` Submodule ${colors.yellow(name)} has new commits in index and HEAD.`); return; // RETURN } // New commit in HEAD but not same as commit we're checking // out. if (wd.status.headCommit !== commit.sha && wd.status.headCommit !== newSha) { errors.push(` Submodule ${colors.yellow(name)} has a new commit.`); return; // RETURN } } });
keys.forEach(function (key) { console.log(''); console.log(colors.yellow(key)); console.log(colors.yellow(new Array(key.length + 1).join('-'))); triggers[key].forEach(function (trigger) { console.log(trigger); }); });
err.issues.forEach((issue) => { if (issue.isWarning) { console.log(`[${issue.src}] ${colors.yellow('WARNING')} ${colors.yellow(issue.message)}`); } else { console.log(`[${issue.src}] ${colors.red('ERROR')} ${colors.red(issue.message)}`); } issueCount++; });
url.errors.forEach(function (e) { if(e.type = 'env'){ result.envError = 1; } msg += ' ' + colors.yellow(util.format("%s", e.type)) + "\n"; msg += ' ' + colors.yellow(util.format("%s", e.message)) + "\n"; if (e.stack) { msg += ' ' + colors.grey(e.stack) + "\n" } })
}, (error, response) => { if (error) { return next(error) } if (response.statusCode !== 200) { return next(new Error(util.format('Could not fetch orders, unknown error, status code:', response.statusCode))) } console.log('Fetched bundle information... (%s/%s)', colors.yellow(++done), colors.yellow(total)) next(null, response.body) })
var changeStatusLed = function (err, state) { if(state == 0) { if (sStatusLed === false) { sStatusLed = true; gStatusLed.writeSync(0); console.log(colors.yellow("The led " + nStatusLed + " is active.")); } else { sStatusLed = false; gStatusLed.writeSync(1); console.log(colors.yellow("The led " + nStatusLed + " is not active.")); }; }; };
request.get(url,{timeout:self.timeout},function(err,response,body){ if(err && err.code == 'ETIMEDOUT'){ console.log('请求超时,正在进行第 ' + self.repeat + ' 次重新请求'); self.repeat ++; //超时重新请求 self.getHtml(url); }else{ //解析html let p = new Htmlparser(body); //提取该页面课程链接 let v = p.getLink(); //如果没有下载链接则跳过 if(!v.length > 0){ console.log(colors.yellow('找不到相关课程')); return self.loopLesson(); } console.log(colors.green('>>>')); console.log(colors.green('+ -正在下载课程《' + p.title.substring(0,25) + '》...')); for(let i=0;i<v.length;i++){ console.log(colors.green('+ --' + v[i]['chapterName'])); for(let j=0;j<v[i]['item'].length;j++){ console.log(colors.green('+ ---' + v[i]['item'][j]['name'])); } } console.log(colors.green('<<<')); //配置该课程本地目录路径 self.lessonPath = self.videoDir + '/' + utils.noneDiagonal(p.title); //检查课程路径是否存在,否则创建新目录 utils.checkFolder(self.lessonPath); //遍历章节 self.loopChapter(v); } })
function failed(name, message, expected, actual) { var output = colors.bold.red('\nTest "%s": Failed --- %s\n'); output += colors.yellow('\tExpected: %s\n'); output += colors.red('\tActual: %s\n'); console.log(output, name, message, expected, actual); return false; }
function editPort(loadJson) { console.clear(); console.log(); console.log(colors.blue.bold('mStream Configuration Wizard')); console.log(colors.magenta('Edit Port')); console.log(); console.log(colors.yellow('Port defaults to 3000 if not set ')); console.log(); return inquirer .prompt([{ message: "Port Number (1 - 65535):", type: "input", name: "port", default: loadJson.port ? loadJson.port : defaults.port, validate: answer => { if (!Number.isInteger(Number(answer)) || Number(answer) < 1 || Number(answer) > 65535) { return 'Port must be a an integer between 1 and 65535!'; } return true; } }]) .then(answers => { return Number(answers.port); }); }
function editAADirectory(loadJson) { console.clear(); console.log(); console.log(colors.blue.bold('mStream Configuration Wizard')); console.log(colors.magenta('Album Art Storage')); console.log(); console.log(colors.yellow('mStream saves all the album art images to one directory. This directory is accessible through the API!')); console.log('By default, mStream uses the `/image-cache` directory') console.log(); console.log(); return inquirer.prompt([{ type: 'directory', name: 'from', message: 'Choose Album Art Folder:', basePath: loadJson.storage.albumArtDirectory ? loadJson.storage.albumArtDirectory : defaults.storage.albumArtDirectory }]).then((answers) => { if (answers.from === defaults.storage.albumArtDirectory) { delete loadJson.storage.albumArtDirectory; } else { loadJson.storage.albumArtDirectory = answers.from; } return answers.from; }); }
verbose: function (filename, action, msg) { if (opts.verbose) { filename = path.relative(process.cwd(), filename); var msg = "++ " + colors.cyan.bold(filename) + ": " + colors.yellow(action) + ": " + msg + "\n"; process.stderr.write(msg); } },
function setScanInterval() { console.clear(); console.log(); console.log(colors.blue.bold('mStream Configuration Wizard')); console.log(colors.magenta('File Scan Interval')); console.log(); console.log(colors.yellow('Sets how often a scan should happen (in hours)')); console.log('Scans happen every 24 hours by default'); console.log(); return inquirer .prompt([{ message: "Scan every __ hours: ", type: "input", name: "interval", default: 24, validate: answer => { if (!Number.isInteger(Number(answer)) || Number(answer) < 0) { return 'Scan Interval cannot be less than 0'; } return true; } }]) .then(answers => { return Number(answers.interval); }); }
function setSaveInterval() { console.clear(); console.log(); console.log(colors.blue.bold('mStream Configuration Wizard')); console.log(colors.magenta('DB Save Interval')); console.log(); console.log(colors.yellow('Sets how often a DB update should happen during a file scan')); console.log('Large libraries (4TB+) can see some performance gains during scan by increasing this'); console.log(); return inquirer .prompt([{ message: "Save DB every __ files: ", type: "input", name: "interval", default: 250, validate: answer => { if (!Number.isInteger(Number(answer)) || Number(answer) < 100) { return 'Save Interval must be a an integer greater than 100!'; } return true; } }]) .then(answers => { return Number(answers.interval); }); }
function log (env, type, mesg) { if (env == 'n') { env = 'NET'; } else if (env == 'w') { env = 'WEB'; } else { env = 'SERVER'; } if (type == 's') { type = colors.green('success:'); } else if (type == 'i') { type = colors.cyan('info:'); } else if (type == 'w') { type = colors.yellow('warning:'); } else if (type == 'e') { type = colors.red('error:'); } else if (type == 'd') { type = colors.grey('debug:'); } if (typeof mesg == 'object') { mesg = colors.italic(colors.grey(JSON.stringify(mesg))); } console.log(' '+'['+colors.bold(colors.white(env))+'] '+colors.bold(type)+' '+mesg); } // log
var pop_task = function() { console.log(clr.yellow('azure_wrapper/task:'), clr.grey(inspect(tasks))); var ret = {}; ret.current = tasks.todo.shift(); ret.remaining = tasks.todo.length; return ret; };
return async.timesSeriesAsync(config.instances, function (n, next) { var droplet_name = config.prefix + '-' + (n+1) var droplet_exists = _.findWhere(droplets.droplets, { name: droplet_name }); if (droplet_exists) { console.log(colors.green(droplet_name + ' already exists.')) next(null, droplet_exists) } else { console.log(colors.yellow(droplet_name + ' does not exist. Creating...')); api.dropletsCreate({ region: config.region, size: config.size, name: droplet_name, image: config.image, ssh_keys: config.ssh_keys, backups: false, ipv6: true, user_data: null, private_networking: config.private_networking }, function (err, body, response) { if (err) throw new Error(err); console.log(colors.green('Droplet created.')) next(null, response.droplet) }) } })
server.listen(WEBPACK_DEV_SERVER_PORT, 'localhost', () => { console.log( `${colors.yellow('WebpackDevServer')} is running on ${colors.underline( `http://localhost:${WEBPACK_DEV_SERVER_PORT}` )}` ); });
var createComponent = (basePath, componentName, className) => { try { console.log(colors.cyan("*".repeat(45))); try { process.chdir(basePath); } catch (e) { console.log(colors.yellow("ERROR: Cannot change dir to base [" + basePath + "]")); console.log(colors.green("Creating new base")); fs.mkdirSync(basePath); process.chdir(basePath); } console.log(colors.green("Creating directory", componentName)); fs.mkdirSync(componentName); process.chdir(componentName); console.log(colors.green("Creating Component " + componentName + '.component.ts')); fs.writeFileSync(componentName + '.component.ts', getComponentContent(basePath, componentName, className)); console.log(colors.green("Creating HTML " + componentName + '.component.html')); fs.writeFileSync(componentName + '.component.html', getHtmlContent(className)); console.log(colors.green("Creating CSS " + componentName + '.component.css')); fs.writeFileSync(componentName + '.component.css', ''); console.log(colors.cyan("*".repeat(45))); } catch (e) { console.error(colors.red("ERROR: ", e)); } };
function check_request_authentication(request, response, next, authorized) { // console.log(colors.yellow("CHECK"), "check new request for authentication"); var auth_header = request.headers.authorization; if (!auth_header) { console.log(colors.red("NO"), "authentication not found"); var err = new Error('authenticate data not found!'); err.status = 401; next(err); return; } var auth_content = auth_header.split(' ')[1]; var auth_content_array = new Buffer(auth_content, "base64") .toString().split(':'); var auth_usr = auth_content_array[0]; var auth_passwd = auth_content_array[1]; var ok = check_database_user(auth_usr, auth_passwd); if (ok) { // authorized if (authorized) { authorized(request, response, auth_usr, auth_passwd); } console.log(colors.green("YES"), request.signedCookies); next(); } else { // not authorized console.log(colors.red("NO"), "user/password not found"); var err = new Error("user/password not found"); err.status = 401; next(err); } }
.data(function (listing){ _num++ cbData && cbData(listing) // 返回数据 console.log(colors.yellow.underline(_num), colors.yellow(listing.article_id)) _log(fmt(_num + listing.article_id + '\n')) })
function setScanPause() { console.clear(); console.log(); console.log(colors.blue.bold('mStream Configuration Wizard')); console.log(colors.magenta('Pause Between Files')); console.log(); console.log(colors.yellow('Sets a pause interval between each file that is scanned (in milliseconds)')); console.log('Scanning large libraries can eat up disk and CPU resources on slower system'); console.log('Setting a pause between files will increase the scan time but reduce system resource usage'); console.log(); return inquirer .prompt([{ message: "Set pause (milliseconds): ", type: "input", name: "pause", default: 0, validate: answer => { if (!Number.isInteger(Number(answer)) || Number(answer) < 0) { return 'Pause cannot be less than 0'; } return true; } }]) .then(answers => { return Number(answers.pause); }); }
encryptor.once('end', function () { var buf = Buffer.concat(chunks) var output = pemtools(buf, 'SALTY MESSAGE') process.stdout.write(colors.yellow(output) + '\n') console.error() self._printHeader(header) })
function setBootDelay() { console.clear(); console.log(); console.log(colors.blue.bold('mStream Configuration Wizard')); console.log(colors.magenta('Boot Scan Delay')); console.log(); console.log(colors.yellow('Sets a delay between server boot and the initial file scan (in seconds)')); console.log('Scanning large libraries can cause a spike in memory usage. And booting the server causes a spike in memory usage'); console.log('By adding a delay between boot and scan, you can reduce the max memory use'); console.log(); return inquirer .prompt([{ message: "Set boot scan delay (seconds): ", type: "input", name: "delay", default: 3, validate: answer => { if (!Number.isInteger(Number(answer)) || Number(answer) < 0) { return 'Delay cannot be less than 0'; } return true; } }]) .then(answers => { return Number(answers.delay); }); }
app.listen(PORT, function () { console.log("API server started on port ".green + colors.yellow(PORT)); //Pass the Mongo variable to all route functions. app.locals.conn = conn; ready.express.resolve(); })
const compile = (files, sourceFolder) => { const createSourceMap = true; console.log(colors.yellow('Warning: This task may take a few minutes on Mac, and even longer on Windows.')); return new Promise((resolve) => { files.forEach(path => { const closureCompiler = require('google-closure-compiler-js'); // const fs = require('fs'); const U = require('./assembler/utilities.js'); const sourcePath = sourceFolder + path; const outputPath = sourcePath.replace('.src.js', '.js'); const src = U.getFile(sourcePath); const out = closureCompiler.compile({ compilationLevel: 'SIMPLE_OPTIMIZATIONS', jsCode: [{ src: src }], languageIn: 'ES5', languageOut: 'ES5', createSourceMap: createSourceMap }); U.writeFile(outputPath, out.compiledCode); if (createSourceMap) { U.writeFile(outputPath + '.map', out.sourceMap); } // @todo add filesize information console.log(colors.green('Compiled ' + sourcePath + ' => ' + outputPath)); }); resolve('Compile is complete'); }); };
(function iter (task) { if (task.current === undefined) { if (conf.destroying === undefined) { create_ssh_conf(); save_state(); } return; } else { if (task.current.length !== 0) { console.log(clr.yellow('azure_wrapper/exec:'), clr.blue(inspect(task.current))); cp.fork('node_modules/azure-cli/bin/azure', task.current) .on('exit', function (code, signal) { tasks.done.push({ code: code, signal: signal, what: task.current.join(' '), remaining: task.remaining, }); if (code !== 0 && conf.destroying === undefined) { console.log(clr.red('azure_wrapper/fail: Exiting due to an error.')); save_state(); console.log(clr.cyan('azure_wrapper/info: You probably want to destroy and re-run.')); process.abort(); } else { iter(pop_task()); } }); } else { iter(pop_task()); } } })(pop_task());
const pushSub = co.wrap(function *(subName) { // Push to a synthetic branch; first, calculate name. const sha = pushMap[subName]; const syntheticName = SyntheticBranchUtil.getSyntheticBranchForCommit(sha); const subRepo = yield SubmoduleUtil.getBareRepo(repo, subName); // Resolve the submodule's URL against the URL of the meta-repo, // ignoring the remote that is configured in the open submodule. const subUrl = SubmoduleConfigUtil.resolveSubmoduleUrl(remoteUrl, urls[subName]); // Always force push synthetic refs. It should not be necessary, but // if something does go wrong forcing will allow us to auto-correct. // If they succeed, no need to print the output inside the submodules. const pushResult = yield GitUtil.push(subRepo, subUrl, sha, syntheticName, true, true); if (null !== pushResult) { errorMessage += `Failed to push submodule ${colors.yellow(subName)}: ${pushResult}`; } });