本文整理汇总了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);
}
示例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());
});
示例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);
}
示例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;
}
示例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()
}
示例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);
});
});
示例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;
}
示例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);
}
示例9: Promise
return new Promise((resolve, reject) => {
outputFileCB(file, data, err => err ? reject(err) : resolve());
});
示例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);