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