本文整理汇总了TypeScript中colors.error函数的典型用法代码示例。如果您正苦于以下问题:TypeScript error函数的具体用法?TypeScript error怎么用?TypeScript error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: stop
/**
* Stop the Laravel Echo server.
*
* @param {object} yargs
* @return {void}
*/
stop(yargs): void {
yargs.option({
config: {
type: 'string',
describe: 'The config file to use.',
},
dir: {
type: 'string',
describe: 'The working directory to use.',
}
});
const configFile = this.getConfigFile(yargs.argv.config, yargs.argv.dir);
const lockFile = path.join(path.dirname(configFile), path.basename(configFile, '.json') + '.lock');
if (fs.existsSync(lockFile)) {
let lockProcess;
try {
lockProcess = parseInt(JSON.parse(fs.readFileSync(lockFile, 'utf8')).process);
} catch {
console.error(colors.error('Error: There was a problem reading the lock file.'));
}
if (lockProcess) {
try {
fs.unlinkSync(lockFile);
process.kill(lockProcess);
console.log(colors.green('Closed the running server.'));
} catch (e) {
console.error(e);
console.log(colors.error('No running servers to close.'));
}
}
} else {
console.log(colors.error('Error: Could not find any lock file.'));
}
}
开发者ID:tlaverdure,项目名称:laravel-echo-server,代码行数:47,代码来源:cli.ts
示例2: readConfigFile
/**
* Tries to read a config file
*
* @param {string} file
* @return {any}
*/
readConfigFile(file): any {
let data = {};
try {
data = JSON.parse(fs.readFileSync(file, 'utf8'));
} catch {
console.error(colors.error('Error: There was a problem reading the config file.'));
process.exit();
}
return this.resolveEnvFileOptions(data);
}
开发者ID:tlaverdure,项目名称:laravel-echo-server,代码行数:18,代码来源:cli.ts
示例3:
fs.access(configFile, fs.F_OK, (error) => {
if (error) {
console.error(colors.error('Error: laravel-echo-server.json file not found.'));
return false;
}
var options = JSON.parse(fs.readFileSync(configFile, 'utf8'));
options.devMode = yargs.argv.dev || options.devMode || false;
echo.run(options);
});
开发者ID:skatetdieu,项目名称:laravel-echo-server,代码行数:13,代码来源:cli.ts
示例4:
fs.writeFile(lockFile, JSON.stringify({ process: process.pid }, null, '\t'), error => {
if (error) {
console.error(colors.error('Error: Cannot write lock file.'));
return false;
}
process.on('exit', () => {
try {
fs.unlinkSync(lockFile);
} catch { }
});
process.on('SIGINT', process.exit);
process.on('SIGHUP', process.exit);
process.on('SIGTERM', process.exit);
echo.run(options);
});
开发者ID:tlaverdure,项目名称:laravel-echo-server,代码行数:19,代码来源:cli.ts
示例5: error
/**
*
*
* Console log info.
*
* @param {string|object} message
* @return {void}
*/
static error(message: any): void {
console.log(colors.error(message));
}
开发者ID:skatetdieu,项目名称:laravel-echo-server,代码行数:11,代码来源:log.ts
示例6: parseInt
fs.access(configFile, fs.F_OK, error => {
if (error) {
console.error(colors.error('Error: The config file cound not be found.'));
return false;
}
const options = this.readConfigFile(configFile);
options.devMode = yargs.argv.dev || options.devMode || false;
const lockFile = path.join(path.dirname(configFile), path.basename(configFile, '.json') + '.lock');
if (fs.existsSync(lockFile)) {
let lockProcess;
try {
lockProcess = parseInt(JSON.parse(fs.readFileSync(lockFile, 'utf8')).process);
} catch {
console.error(colors.error('Error: There was a problem reading the existing lock file.'));
}
if (lockProcess) {
try {
if (process.kill(lockProcess, 0)) {
if (yargs.argv.force) {
process.kill(lockProcess);
console.log(colors.yellow('Warning: Closing process ' + lockProcess + ' because you used the \'--force\' option.'));
} else {
console.error(colors.error('Error: There is already a server running! Use add the option \'--force\' to stop it and start another one.'));
return false;
}
}
} catch {
// The process in the lock file doesn't exist, so continue
}
}
}
fs.writeFile(lockFile, JSON.stringify({ process: process.pid }, null, '\t'), error => {
if (error) {
console.error(colors.error('Error: Cannot write lock file.'));
return false;
}
process.on('exit', () => {
try {
fs.unlinkSync(lockFile);
} catch { }
});
process.on('SIGINT', process.exit);
process.on('SIGHUP', process.exit);
process.on('SIGTERM', process.exit);
echo.run(options);
});
});
开发者ID:tlaverdure,项目名称:laravel-echo-server,代码行数:61,代码来源:cli.ts
注:本文中的colors.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论