本文整理汇总了TypeScript中sander.writeFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript writeFile函数的具体用法?TypeScript writeFile怎么用?TypeScript writeFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeFile函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Promise
return new Promise((res, rej) => {
Promise.all([
// settings
sander.writeFile(join(workingDir, "bits", bitName, `${bitName}.bitSettings.js`), manifest.bits[bitName].settings),
// script
sander.writeFile(join(workingDir, "bits", bitName, manifest.bits[bitName].script.file), manifest.bits[bitName].script.contents),
// style
sander.writeFile(join(workingDir, "bits", bitName, manifest.bits[bitName].style.file), manifest.bits[bitName].style.contents),
// html
sander.writeFile(join(workingDir, "bits", bitName, manifest.bits[bitName].html.file), manifest.bits[bitName].html.contents)
]).then(res).catch(rej);
});
示例2: installCommand
export async function installCommand(config: Config, args) {
const path = args["p"] || args["path"] || process.cwd();
const fname = args["f"] || args["fetcher"] || "default";
const FETCHER = config.fetchers[fname];
let ledeModulesToInstall: string[] = args["_"];
let addToPackageJson = true;
const workingDir = await searchForProjectDir(path);
if (ledeModulesToInstall.length === 0) {
ledeModulesToInstall = await loadFromPackage(workingDir);
addToPackageJson = false;
}
await Promise.all(ledeModulesToInstall.map(install.bind({ fetcher: FETCHER, workingDir: join(workingDir, config.caches.DEP_CACHE) })))
if (addToPackageJson) {
let p = await sander.readFile(join(workingDir, "package.json"), {encoding: "utf8"});
p = JSON.parse(p);
if (p.ledeModules && Array.isArray(p.ledeModules)) {
p.ledeModules.concat(ledeModulesToInstall)
} else {
p.ledeModules = ledeModulesToInstall;
}
await sander.writeFile(join(workingDir, "package.json"), JSON.stringify(p, null, 2));
}
ledeModulesToInstall.forEach(m => config.logger.info(`Finished installing ${m}`));
}
示例3: deploy
async deploy(page: CompiledPage): Promise<any> {
const files = page.files.map(f => {
if (f.content) {
return sander.writeFile(join(this.deployDir, page.path, f.name), f.content);
}
return sander.copyFile(f.path).to(join(this.deployDir, page.path, f.overridableName || f.name));
});
return Promise.all([
sander.writeFile(join(this.deployDir, page.path, "index.html"), page.renderedPage),
...files
]);
}
示例4: function
return function(file) {
return sander.writeFile(join(workingDir, type, file.file), file.contents)
}
示例5:
Promise.all(manifest.blocks.map(block => {
return sander.writeFile(join(workingDir, "blocks", block.file), block.contents)
})).then(resolve)
示例6:
const files = page.files.map(f => {
if (f.content) {
return sander.writeFile(join(this.deployDir, page.path, f.name), f.content);
}
return sander.copyFile(f.path).to(join(this.deployDir, page.path, f.overridableName || f.name));
});