当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Q.nfcall函数代码示例

本文整理汇总了TypeScript中Q.nfcall函数的典型用法代码示例。如果您正苦于以下问题:TypeScript nfcall函数的具体用法?TypeScript nfcall怎么用?TypeScript nfcall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了nfcall函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

 return Q.nfcall<fs.Stats>(fs.stat, p).then((stats: fs.Stats) => {
     if (stats.isDirectory()) {
         return Q.nfcall<string[]>(fs.readdir, p).then((childPaths: string[]) => {
             let result = Q<void>(void 0);
             childPaths.forEach(childPath =>
                 result = result.then<void>(() => this.removePathRecursivelyAsync(path.join(p, childPath))));
             return result;
         }).then(() =>
             Q.nfcall<void>(fs.rmdir, p));
     } else {
         /* file */
         return Q.nfcall<void>(fs.unlink, p);
     }
 });
开发者ID:ajwhite,项目名称:vscode-react-native,代码行数:14,代码来源:fileSystem.ts

示例2: runTest

    function runTest(testFileName: string) {
        const testFilePath = path.resolve(__dirname, '..', 'fixtures', testFileName);

        logger.info({testFilePath: testFilePath}, 'Running test file');

        return q.nfcall(tmp.file.bind(tmp), {postfix: '.js'})
            .spread(function(jsOutputFilePath: string) {
                logger.info({jsOutputFilePath: jsOutputFilePath, lsc: lsc}, 'Compiling to js output');
                return lsc(testFilePath, jsOutputFilePath)
                    .then(function() {
                        const command = `node ${jsOutputFilePath}`;
                        logger.info({command: command}, 'Spawning node on generated js');
                        return q.nfcall(child_process.exec.bind(child_process), command);
                    })
                    .fail(function(err: any) {
                        logger.error(err, 'lsc failed');
                        throw err;
                    });
            }).spread(function(stdout: Buffer, stderr: Buffer) {
                if (stderr.length) {
                   throw new Error(stderr.toString());
                }

                logger.info({stdout: stdout.toString()}, 'Nodejs spawn complete');
                return stdout.toString();
            });
    }
开发者ID:NickHeiner,项目名称:lambdascript,代码行数:27,代码来源:index.ts

示例3: getHistoryModel

export function getHistoryModel(
    options,
    basePath = remote.app.getPath('userData')
) {
    let buffer: any[] = []
    let promise = q()
    const fileName = basePath + '/' + options.file
    const history = {
        push(item) {
            promise = promise.then(() => {
                buffer.splice(0, 0, item)
                if (buffer.length > options.max) {
                    buffer = buffer.slice(0, options.min)
                }
                return q.nfcall(
                    writeFile,
                    fileName,
                    buffer.map(obj => JSON.stringify(obj)).join(',')
                )
            })
            return promise
        },
        list: () => buffer,
    }
    return q.nfcall(readFile, fileName).then(
        content => {
            buffer = JSON.parse('[' + content + ']')
            return history
        },
        () => history
    )
}
开发者ID:jakobrun,项目名称:gandalf,代码行数:32,代码来源:history.ts

示例4: file

 Q.all([Q.nfcall(fs.exists, jsconfigPath), Q.nfcall(fs.exists, tsconfigPath)]).spread((jsExists: boolean, tsExists: boolean) => {
     if (!jsExists && !tsExists) {
         Q.nfcall(fs.writeFile, jsconfigPath, "{}").then(() => {
             // Any open file must be reloaded to enable intellisense on them, so inform the user
             vscode.window.showInformationMessage("A 'jsconfig.json' file was created to enable IntelliSense. You may need to reload your open JS file(s).");
         });
     }
 });
开发者ID:dahomost,项目名称:vscode-cordova,代码行数:8,代码来源:cordova.ts

示例5:

            .then(function(exists: boolean) {
                if (!exists) {
                    return Q.nfcall(child_process.exec, `npm install --prefix ${typeScriptNextDest} typescript@next`)
                        .then(() => { return true; });
                }

                return isRestartRequired;
            });
开发者ID:ajwhite,项目名称:vscode-react-native,代码行数:8,代码来源:intellisenseHelper.ts

示例6: findFilesByExtension

 public findFilesByExtension(folder: string, extension: string): Q.Promise<string[]> {
     return Q.nfcall(fs.readdir, folder).then((files: string[]) => {
         const extFiles = files.filter((file: string) => path.extname(file) === `.${extension}`);
         if (extFiles.length === 0) {
             throw new Error(`Unable to find any ${extension} files.`);
         }
         return extFiles;
     });
 }
开发者ID:ajwhite,项目名称:vscode-react-native,代码行数:9,代码来源:fileSystem.ts

示例7: exists

 /**
  *  Helper (asynchronous) function to check if a file or directory exists
  */
 public exists(filename: string): Q.Promise<boolean> {
     return Q.nfcall(fs.stat, filename)
         .then(function() {
             return Q.resolve(true);
         })
         .catch(function(err) {
             return Q.resolve(false);
         });
 }
开发者ID:ajwhite,项目名称:vscode-react-native,代码行数:12,代码来源:fileSystem.ts

示例8:

 promise = promise.then(() => {
     buffer.splice(0, 0, item)
     if (buffer.length > options.max) {
         buffer = buffer.slice(0, options.min)
     }
     return q.nfcall(
         writeFile,
         fileName,
         buffer.map(obj => JSON.stringify(obj)).join(',')
     )
 })
开发者ID:jakobrun,项目名称:gandalf,代码行数:11,代码来源:history.ts

示例9: getBundleIdentifier

 public static getBundleIdentifier(projectRoot: string): Q.Promise<string> {
     return Q.nfcall(fs.readdir, path.join(projectRoot, 'platforms', 'ios')).then((files: string[]) => {
         let xcodeprojfiles = files.filter((file: string) => /\.xcodeproj$/.test(file));
         if (xcodeprojfiles.length === 0) {
             throw new Error('Unable to find xcodeproj file');
         }
         let xcodeprojfile = xcodeprojfiles[0];
         let projectName = /^(.*)\.xcodeproj/.exec(xcodeprojfile)[1];
         let plist = pl.parseFileSync(path.join(projectRoot, 'platforms', 'ios', projectName, projectName + '-Info.plist'));
         return plist.CFBundleIdentifier;
     });
 }
开发者ID:Paradox-Cascade,项目名称:vscode-cordova,代码行数:12,代码来源:cordovaIosDeviceLauncher.ts

示例10: ensureNuGetDownloads

async function ensureNuGetDownloads(): Promise<void> {
    if (!fs.existsSync(tempDir)) {
        await Q.nfcall(fs.mkdir, tempDir);
    }

    for (let i of nuGetVersions) {
        if (!fs.existsSync(i.filePath)) {
            // tslint:disable-next-line
            console.log(`Downloading ${i.url} to ${i.filePath}`);
            await download(i.url, i.filePath);
        }
    }
}
开发者ID:ReneSchumacher,项目名称:VSTS-Tasks,代码行数:13,代码来源:readNuGetExeFileVersion.ts


注:本文中的Q.nfcall函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。