當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript log.writeln方法代碼示例

本文整理匯總了TypeScript中grunt.log.writeln方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript log.writeln方法的具體用法?TypeScript log.writeln怎麽用?TypeScript log.writeln使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在grunt.log的用法示例。


在下文中一共展示了log.writeln方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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);
    }
}
開發者ID:MasGaNo,項目名稱:grunt-ts,代碼行數:12,代碼來源:cacheUtils.ts

示例2: 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) => {
開發者ID:ThaNarie,項目名稱:grunt-ts,代碼行數:14,代碼來源:compile.ts

示例3: 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);
        }
//.........這裏部分代碼省略.........
開發者ID:ThaNarie,項目名稱:grunt-ts,代碼行數:101,代碼來源:compile.ts

示例4: 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');
}
開發者ID:ThaNarie,項目名稱:grunt-ts,代碼行數:6,代碼來源:compile.ts

示例5:

 _.forEach(files, (file) => {
     grunt.log.writeln(('### Fast Compile >>' + file).cyan);
 });
開發者ID:ThaNarie,項目名稱:grunt-ts,代碼行數:3,代碼來源:compile.ts


注:本文中的grunt.log.writeln方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。