本文整理汇总了TypeScript中grunt.log.write方法的典型用法代码示例。如果您正苦于以下问题:TypeScript log.write方法的具体用法?TypeScript log.write怎么用?TypeScript log.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grunt.log
的用法示例。
在下文中一共展示了log.write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: compileAllFiles
export function compileAllFiles(targetFiles: string[], target: ITargetOptions, task: ITaskOptions): Promise<ICompileResult> {
// Make a local copy so we can modify files without having external side effects
var files = _.map(targetFiles, (file) => file);
var newFiles: string[] = files;
if (task.fast) {
if (target.out) {
grunt.log.write('Fast compile will not work when --out is specified. Ignoring fast compilation'.red);
}
else {
newFiles = getChangedFiles(files);
if (newFiles.length !== 0) { files = newFiles; }
else {
grunt.log.writeln('No file changes were detected. Skipping Compile'.green);
return new Promise((resolve) => {
var ret: ICompileResult = {
code: 0,
fileCount: 0,
output: 'No files compiled as no change detected'
};
resolve(ret);
});
}
}
}
// Transform files as needed. Currently all of this logic in is one module
transformers.transformFiles(newFiles, targetFiles, target, task);
// If baseDir is specified create a temp tsc file to make sure that `--outDir` works fine
// see https://github.com/grunt-ts/grunt-ts/issues/77
var baseDirFile: string = 'ignoreBaseDirFile.ts';
var baseDirFilePath: string;
if (target.outDir && target.baseDir && files.length > 0) {
baseDirFilePath = path.join(target.baseDir, baseDirFile);
if (!fs.existsSync(baseDirFilePath)) {
grunt.file.write(baseDirFilePath, '// Ignore this file. See https://github.com/grunt-ts/grunt-ts/issues/77');
}
files.push(baseDirFilePath);
}
// If reference and out are both specified.
// Then only compile the updated reference file as that contains the correct order
if (target.reference && target.out) {
var referenceFile = path.resolve(target.reference);
files = [referenceFile];
}
// Quote the files to compile. Needed for command line parsing by tsc
files = _.map(files, (item) => '"' + path.resolve(item) + '"');
var args: string[] = files.slice(0);
// boolean options
if (task.sourceMap) {
args.push('--sourcemap');
}
if (task.declaration) {
args.push('--declaration');
}
if (task.removeComments) {
args.push('--removeComments');
}
if (task.noImplicitAny) {
args.push('--noImplicitAny');
}
if (task.noResolve) {
args.push('--noResolve');
}
// string options
args.push('--target', task.target.toUpperCase());
args.push('--module', task.module.toLowerCase());
// Target options:
if (target.out) {
args.push('--out', target.out);
}
if (target.outDir) {
if (target.out) {
console.warn('WARNING: Option "out" and "outDir" should not be used together'.magenta);
}
args.push('--outDir', target.outDir);
}
if (task.sourceRoot) {
args.push('--sourceRoot', task.sourceRoot);
}
if (task.mapRoot) {
args.push('--mapRoot', task.mapRoot);
}
// Locate a compiler
var tsc = getTsc(resolveTypeScriptBinPath());
// To debug the tsc command
if (task.verbose) {
console.log(args.join(' ').yellow);
}
else {
//.........这里部分代码省略.........