當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。