本文整理汇总了TypeScript中grunt.log类的典型用法代码示例。如果您正苦于以下问题:TypeScript log类的具体用法?TypeScript log怎么用?TypeScript log使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了log类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: callback
(err, result, code) => {
grunt.verbose.writeln(String(result));
if (err) {
grunt.log.errorlns(err);
callback(err);
} else {
grunt.log.ok(config.cmd + ' ' + config.args.join(' ') + ' completed.');
callback(null, true);
}
});
示例2: clearCache
export function clearCache(targetName) {
var cacheDirForTarget = path.join(cacheDir, targetName);
try {
if (fs.existsSync(cacheDirForTarget)) {
rimraf.sync(cacheDirForTarget);
grunt.log.writeln(('Cleared fast compile cache for target: ' + targetName).cyan);
}
}
catch (ex) {
grunt.log.writeln(('Failed to clear compile cache for target: ' + targetName).red);
}
}
示例3: runSocko
/**
* Calls socko to generate the output node
* @return {Bluebird<SockoNodeInterface>} the output node
*/
private runSocko (): Bluebird<SockoNodeInterface> {
grunt.log.subhead('Running socko')
let processorOptions = new ProcessorOptionsFactory().create()
if (this._options.ignores && this._options.ignores.length > 0) {
let ignoreObject = new Map<string, string>()
for (let ignoreOption of this._options.ignores) {
let ignoreSplit = ignoreOption.split(/=/)
if (ignoreSplit.length === 1) {
ignoreSplit.unshift('*')
}
ignoreObject.set(ignoreSplit[1], ignoreSplit[0])
}
processorOptions.processCartridgeNode = node => {
if (ignoreObject.has(node.name)) {
if (ignoreObject.get(node.name) === '*') {
return Bluebird.resolve(new SkippedNodeBuilder().build())
} else {
return node.getPath(':')
.then(
value => {
if (`${ignoreObject.get(node.name)}:${node.name}` === value) {
return Bluebird.resolve(new SkippedNodeBuilder().build())
} else {
return Bluebird.resolve(node)
}
}
)
}
} else {
return Bluebird.resolve(node)
}
}
}
if (this._options.renames && this._options.renames.length > 0) {
let renameObject = new Map<string, string>()
for (let renameOption of this._options.renames) {
let splitRenameOption = renameOption.split(/:/)
renameObject.set(splitRenameOption[0], splitRenameOption[1])
}
processorOptions.processResultTreeNode = node => {
if (renameObject.has(node.name)) {
node.name = renameObject.get(node.name)
}
return Bluebird.resolve(node)
}
}
processorOptions.allowEmptyCartridgeSlots = this._options.ignoreMissing
return new SockoProcessor().process(
this._trees.sockoInput,
this._trees.sockoNode,
processorOptions
)
}
示例4: convertToSockoTrees
/**
* Converts the `FileTree`s to `SockoTree`s
* @return {Bluebird<void>}
*/
private convertToSockoTrees (): Bluebird<void> {
grunt.log.subhead('Converting file trees to socko trees')
let inputConverterOptions = new ConverterOptionsFactory().create()
let inputConverter = new FileToTreeConverter(inputConverterOptions)
let hierarchyConverterOptions = new ConverterOptionsFactory().create()
let hierarchyConverter = new FileToTreeConverter(hierarchyConverterOptions)
return Bluebird.props({
input: inputConverter.convert(this._trees.fileInput),
hierarchy: hierarchyConverter.convert(this._trees.fileHierarchy)
})
.then(
trees => {
this._trees.sockoHierarchy = trees.hierarchy
this._trees.sockoInput = trees.input
return this._trees.sockoHierarchy.getNodeByPath(`:_root:${this._options.node}`, ':')
}
)
.then(
node => {
this._trees.sockoNode = node as SockoNodeInterface
return Bluebird.resolve()
}
)
}
示例5: convertToFileTrees
/**
* Converts the directories to `FileTree`
* @return {Bluebird<void>}
*/
private convertToFileTrees (): Bluebird<void> {
grunt.log.subhead('Converting fileInput and fileHierarchy directories to tree.')
grunt.log.verbose.writeln('Ignoring fileHierarchy path in fileInput path and vice versa while doing so.')
let inputScanOptions = new ScanOptions(this._paths.input)
if (this._paths.hierarchy.startsWith(this._paths.input)) {
inputScanOptions.filter = (filterPath, entry) => {
return Bluebird.resolve(!path.join(filterPath, entry).endsWith(this._paths.hierarchy))
}
}
let hierarchyScanOptions = new ScanOptions(this._paths.hierarchy)
if (this._paths.input.startsWith(this._paths.hierarchy)) {
hierarchyScanOptions.filter = (filterPath, entry) => {
return Bluebird.resolve(!path.join(filterPath, entry).endsWith(this._paths.input))
}
}
return Bluebird.props({
input: new FileNode().scan(inputScanOptions),
hierarchy: new FileNode().scan(hierarchyScanOptions)
})
.then(
trees => {
this._trees.fileHierarchy = trees.hierarchy
this._trees.fileInput = trees.input
return Bluebird.resolve()
}
)
}
示例6: taskFunction
export function taskFunction (this: grunt.task.ITask): void {
let done = this.async()
let options = this.options<SockoOptionsInterface>({
input: null,
output: null,
node: null,
ignores: [],
renames: [],
skipIdenticalSockets: false,
clean: false,
hierarchy: null,
ignoreMissing: false
})
if (!options.input) {
grunt.log.error('Please specify an fileInput directory')
done(false)
}
if (!options.output) {
grunt.log.error('Please specify an output directory')
done(false)
}
if (!options.node) {
grunt.log.error('Please specify a node')
done(false)
}
let runner = new SockoRunner(options)
runner.run()
.catch(
(error) => {
grunt.log.error(error.message)
done(false)
}
)
.then(
() => {
done()
}
)
}
示例7: convertFromOutputNode
/**
* Converts the output node to a directory with files
* @param {SockoNodeInterface} outputNode the output node to generate
* @return {Bluebird<void>}
*/
private convertFromOutputNode (outputNode: SockoNodeInterface): Bluebird<void> {
grunt.log.subhead('Converting output tree to directory')
let converterOptions = new ConverterOptionsFactory().create()
converterOptions.checkBeforeOverwrite = this._options.skipIdenticalSockets
converterOptions.outputPath = this._paths.output
return new TreeToFileConverter(converterOptions).convert(outputNode)
}
示例8: executeNode
return executeNode([tsc, '@' + tempfilename]).then((result: ICompileResult) => {
if (task.fast !== 'never' && result.code === 0) {
resetChangedFiles(newFiles, targetName);
}
result.fileCount = files.length;
fs.unlinkSync(tempfilename);
grunt.log.writeln(result.output);
return Promise.cast(result);
}, (err) => {
示例9: compileAllFiles
export function compileAllFiles(targetFiles: string[], target: ITargetOptions, task: ITaskOptions, targetName: string): 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 === 'watch') { // if we only do fast compile if target is watched
// if this is the first time its running after this file was loaded
if (cacheClearedOnce[grunt.task.current.target] === undefined) {
// Then clear the cache for this target
clearCache(targetName);
}
}
if (task.fast !== 'never') {
if (target.out) {
grunt.log.writeln('Fast compile will not work when --out is specified. Ignoring fast compilation'.cyan);
}
else {
newFiles = getChangedFiles(files, targetName);
if (newFiles.length !== 0) {
files = newFiles;
// If outDir is specified but no baseDir is specified we need to determine one
if (target.outDir && !target.baseDir) {
target.baseDir = utils.findCommonPath(files, '/');
}
}
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 = '.baseDir.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);
}
//.........这里部分代码省略.........
示例10: getTsc
function getTsc(binPath: string): string {
var pkg = JSON.parse(fs.readFileSync(path.resolve(binPath, '..', 'package.json')).toString());
grunt.log.writeln('Using tsc v' + pkg.version);
return path.join(binPath, 'tsc');
}