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


TypeScript fs-extra.outputFile函數代碼示例

本文整理匯總了TypeScript中fs-extra.outputFile函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript outputFile函數的具體用法?TypeScript outputFile怎麽用?TypeScript outputFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: generateRepoToc

export async function generateRepoToc(
  userName,
  repository,
  basePath = '/',
  useSubHeader = false
) {
  // 獲取到 Repository 對象
  const repo = gh.getRepo(userName, repository);

  currentDepth = 0;

  const fileTree = await dfsWalkToGenerateFileTree(repo, '/', basePath);

  let toc;

  if (useSubHeader) {
    toc = await generateTocFromFileTreeWithSubHeader(fileTree, currentDepth);
  } else {
    toc = await generateTocFromFileTree(
      fileTree,
      `https://github.com/${userName}/${repository}/${basePath}`
    );
  }

  fs.outputFile('toc.md', toc);
}
開發者ID:wxyyxc1992,項目名稱:ConfigurableAPIServer,代碼行數:26,代碼來源:generateTocFromRemote.ts

示例2: readFile

 readFile(join(targetPath, 'js', jsFileName), { encoding: 'utf8' }).then((file) => {
     if (buildName === 'desktop') {
         file = `(function () {\nvar module = undefined;\n${file}})();`;
     }
     outputFile(join(targetPath, 'js', jsFileName), file)
         .then(() => done());
 });
開發者ID:wavesplatform,項目名稱:WavesGUI,代碼行數:7,代碼來源:gulpfile.ts

示例3: writeFileMap

async function writeFileMap(
    rootDir: string, files: Map<string, string>): Promise<void> {
  const promises = [];
  for (const [relPath, contents] of files) {
    const fullPath = path.join(rootDir, relPath);
    promises.push(fsExtra.outputFile(fullPath, contents));
  }
  await Promise.all(promises);
}
開發者ID:Polymer,項目名稱:tools,代碼行數:9,代碼來源:cli.ts

示例4: getTempPath

const withTempFile = (filePath: string, bufferText: string) : PromiseLike<string> => {
    const tempFilePath = getTempPath(filePath);
    const p = Promise.defer<string>();
    fs.outputFile(tempFilePath, bufferText, (err) => {
        if (err)
            p.reject("error with file");
        else 
            p.resolve(tempFilePath);
    });
    return p.promise; 
} 
開發者ID:hedefalk,項目名稱:ensime-node,代碼行數:11,代碼來源:server-api.ts

示例5: async

 const refresh = async () => {
   await fs.outputFile(refreshFile, '')
   spawn(
     process.execPath,
     [path.join(__dirname, '../../../lib/hooks/init/refresh-run')],
     {
       detached: !this.config.windows,
       // stdio: 'inherit',
       stdio: 'ignore',
     }
   ).unref()
 }
開發者ID:jimmyurl,項目名稱:cli,代碼行數:12,代碼來源:refresh.ts

示例6: Promise

    return new Promise((resolve: (val: boolean) => void, reject: (val: string) => void) => {
      const filePath: string = this.getFilePath(key);
      const meta: string = JSON.stringify({
        expireTime: Math.floor((new Date()).getTime() / 1000) + duration,
      });
      const data: Buffer = new Buffer([meta, value].join('\n'));

      fs.outputFile(filePath, data, (err: string) => {
        if (err) {
          return reject(err);
        }

        resolve(true);
      });
    });
開發者ID:RapidFiring,項目名稱:nodetests,代碼行數:15,代碼來源:file.ts

示例7: finished

 // =======================================================================================================================================
 // =======================================================================================================================================
 // =======================================================================================================================================
 function finished(config) {
     const defaultOptions: {} = {
         autoRefresh: false,
         browser: 'Google Chrome Canary',
         pollTimeout: 1200,
         debugOnly: true,
         debugFilter: 'USER_DEBUG|FATAL_ERROR',
         apiVersion: '38.0',
         deployOptions: {
             'checkOnly': false,
             'testLevel': 'runLocalTests',
             'verbose': false,
             'ignoreWarnings': true,
         },
     };
     fs.outputFile(vscode.workspace.rootPath + path.sep + 'force.json', JSON.stringify(Object.assign(defaultOptions, config), undefined, 4));
     return config;
 }
開發者ID:mgarf,項目名稱:ForceCode,代碼行數:21,代碼來源:credentials.ts

示例8: generateToc

export async function generateToc(repoName = 'Awesome-Reference') {
  // 獲取倉庫的配置信息
  const repo: ReposityConfig = repos[repoName];

  const files = walkSync(repo.localPath).filter(
    path => path.endsWith('.md') && path !== 'README.md'
  );

  // 暫時不進行文件頭添加操作
  // for (let file of files) {
  //   const absoluteFile = `${repo.localPath}/${file}`;

  //   // 讀取文件內容
  //   let content = await readFileAsync(absoluteFile, { encoding: 'utf8' });

  //   const header = `[![返回目錄](${repo.chapterHeader})](${repo.sUrl}) \n`;

  //   // 替換已經存在的圖片
  //   content = content.replace(/\[!\[返回目錄\]\(.*\)\]\(.*\)/g, '');

  //   content = header + content;

  //   fs.outputFile(absoluteFile, content);
  // }

  let fileTree = await generateFileTree(repo.localPath);

  let toc;

  if (repo.depth === 1) {
    toc = generateTocFromFileTree(fileTree);
  } else {
    toc = generateTocFromFileTreeWithSubHeader(fileTree, 0);
  }

  fs.outputFile('toc.md', toc);
}
開發者ID:wxyyxc1992,項目名稱:ConfigurableAPIServer,代碼行數:37,代碼來源:generateTocFromLocal.ts

示例9: Promise

 return new Promise((resolve, reject) => {
   outputFileCB(file, data, err => err ? reject(err) : resolve());
 });
開發者ID:overlandjs,項目名稱:ltd,代碼行數:3,代碼來源:utils.ts

示例10:

		filter: /.*/
	}
);
fs.createFile(file, errorCallback);
fs.createFileSync(file);

fs.mkdirs(dir, errorCallback);
fs.mkdirs(dir, {}, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirsSync(dir, {});
fs.mkdirp(dir, errorCallback);
fs.mkdirp(dir, {}, errorCallback);
fs.mkdirpSync(dir);
fs.mkdirpSync(dir, {});

fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);
fs.outputJson(file, data, errorCallback);
fs.outputJSON(file, data, errorCallback);

fs.outputJsonSync(file, data);
fs.outputJSONSync(file, data);

fs.readJson(file, (error: Error, jsonObject: any) => {});
fs.readJson(file, readOptions, (error: Error, jsonObject: any) => {});
fs.readJSON(file, (error: Error, jsonObject: any) => {});
fs.readJSON(file, readOptions, (error: Error, jsonObject: any) => {});

fs.readJsonSync(file, readOptions);
fs.readJSONSync(file, readOptions);
開發者ID:YousefED,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:fs-extra-tests.ts


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