本文整理汇总了TypeScript中fs-extra-promise.ensureDirAsync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ensureDirAsync函数的具体用法?TypeScript ensureDirAsync怎么用?TypeScript ensureDirAsync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ensureDirAsync函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: generateTypescript
export async function generateTypescript (columns: IColumn[], dir: string) {
const DIR = resolve(dir);
await removeAsync(DIR);
await ensureDirAsync(DIR);
const schemas = mapSchemas(columns);
// tslint:disable-next-line:forin
for (const schema in schemas) {
const schemaDir = resolve(DIR, schema);
let outputInterfaces = '';
// tslint:disable-next-line:forin
for (const table in schemas[schema]) {
const interfaceName = normalizeTableName(table);
const interfaceContent = schemas[schema][table].map(col => col.type).join('\n');
outputInterfaces += `
export interface ${ interfaceName } {
${ interfaceContent }
}
`;
}
await ensureDirAsync(schemaDir);
await writeTypescriptFile(join(schemaDir, INDEX), outputInterfaces);
}
await writeTypescriptFile(join(DIR, INDEX), `
${ Object.keys(schemas).map(schema => `
import * as ${ schema } from './${ schema }';
export { ${ schema } };
` ).join('') }
`);
}
示例2: promptToAddAssets
promptToAddAssets().then(addAssets => {
if (!addAssets) {
return;
}
const paths = getPaths();
return fs.ensureDirAsync(paths.vscodeFolder).then(() => {
return Promise.all([
addTasksJsonIfNecessary(info.DotNet, paths, operations),
addLaunchJsonIfNecessary(info.DotNet, paths, operations)
]);
});
});
示例3: writeTypescriptFile
async function writeTypescriptFile (filename: string, output: string) {
const result = await processString('', output.trim(), {
replace: false,
verify: false,
tsconfig: false,
tslint: false,
editorconfig: false,
tsfmt: true,
tsconfigFile: null,
tslintFile: null,
tsfmtFile: null,
vscode: false,
vscodeFile: null
});
await ensureDirAsync(dirname(filename));
await writeFileAsync(filename, result.dest, { encoding: 'utf-8' });
}