本文整理匯總了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);