本文整理汇总了TypeScript中fs-extra.mkdirSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mkdirSync函数的具体用法?TypeScript mkdirSync怎么用?TypeScript mkdirSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkdirSync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const setCleanTestCwd = () => {
const random = crypto.randomBytes(16).toString("hex");
const path = `${os.tmpdir()}/fs-jetpack-test-${random}`;
fse.mkdirSync(path);
createdDirectories.push(path);
process.chdir(path);
};
示例2: function
walk.dirsSync(dataDirectory, function(dir: string, file: string, stat: any) {
// Combine them together into the directories.
var distDir = dir.replace(dataDirectory, distDirectory);
var distDataDir = path.join(distDir, file);
// Create the directory if it doesn't exist.
if (!fs.existsSync(distDataDir)) {
fs.mkdirSync(distDataDir);
}
});
示例3: generate
public generate() {
this.cloneTemplate();
const dir = this.config.name;
const templateRepo = PlatformConfig.getRepository();
const templateProjectName = GitGen.getRepoName(templateRepo.client);
const replacePattern = { [templateProjectName]: dir };
copySync(`${dir}/resources/gitignore/variantConfig.ts`, `${dir}/src/config/variantConfig.ts`);
// for installing plugins this folder must exist
mkdirSync(`${dir}/vesta/cordova/www`);
findInFileAndReplace(`${dir}/vesta/cordova/config.xml`, replacePattern);
}
示例4:
nodes.forEach((node, index) => {
tmpPath = path.join(tmpPath, node);
if (fs.existsSync(tmpPath)) {
return;
}
if (index === nodes.length - 1) {
fs.writeFileSync(tmpPath, '');
} else {
fs.mkdirSync(tmpPath);
}
});
示例5: it
it('ng generate module child should work in sub-dir', function () {
fs.mkdirSync(path.join(testPath, './sub-dir'));
return new Promise(resolve => {
process.chdir(path.join(testPath, './sub-dir'));
return resolve();
}).then(() =>
ng(['generate', 'module', 'child']).then(() => {
expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child.module.ts'))).to.equal(true);
expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child.module.spec.ts'))).to.equal(false);
})
);
});
示例6: it
it('ng generate module child should work in sub-dir with routing file when passed --routing flag', (done) => {
fs.mkdirSync(path.join(testPath, './sub-dir'));
return new Promise(resolve => {
process.chdir(path.join(testPath, './sub-dir'));
return resolve();
})
.then(() => ng(['generate', 'module', 'child', '--routing']))
.then(() => {
expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child.module.ts'))).toBe(true);
expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child-routing.module.ts'))).toBe(true);
expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child.module.spec.ts'))).toBe(false);
})
.then(done, done.fail);
});
示例7: createTemporaryDir
export function createTemporaryDir(projectPath: string): string {
let temporaryDir = path.join(projectPath, Constants.tempPath);
let counter = Constants.defaultCounter;
while (counter--) {
const result = fs.pathExistsSync(temporaryDir);
if (result) {
temporaryDir = temporaryDir.concat(Math.floor(Math.random() * 10).toString());
} else {
fs.mkdirSync(temporaryDir);
break;
}
}
return temporaryDir;
}
示例8: copy
.map((fileName) => {
const source = path.join(packagesRoot, fileName);
const dest = path.join(dist, fileName);
if (fs.statSync(source).isDirectory()) {
try {
fs.mkdirSync(dest);
} catch (err) {
if (err.code != 'EEXIST') {
throw err;
}
}
} else {
return copy(source, dest);
}
})
示例9: function
export default function() {
const root = process.cwd();
const modulePath = join(root, 'src', 'app', 'app.module.ts');
fs.mkdirSync('./src/app/sub-dir');
return ng('generate', 'service', 'test-service', '--module', 'app.module.ts')
.then(() => expectFileToMatch(modulePath,
/import { TestServiceService } from '.\/test-service.service'/))
.then(() => process.chdir(join(root, 'src', 'app')))
.then(() => ng('generate', 'service', 'test-service2', '--module', 'app.module.ts'))
.then(() => expectFileToMatch(modulePath,
/import { TestService2Service } from '.\/test-service2.service'/))
// Try to run the unit tests.
.then(() => ng('build'));
}
示例10: function
export default function() {
const root = process.cwd();
const modulePath = join(root, 'src', 'app', 'app.module.ts');
fs.mkdirSync('./src/app/sub-dir');
return ng('generate', 'guard', 'test-guard', '--module', 'app.module.ts')
.then(() => expectFileToMatch(modulePath,
/import { TestGuardGuard } from '.\/test-guard.guard'/))
.then(() => expectFileToMatch(modulePath,
/providers:\s*\[TestGuardGuard\]/m))
.then(() => process.chdir(join(root, 'src', 'app')))
.then(() => ng('generate', 'guard', 'test-guard2', '--module', 'app.module.ts'))
.then(() => expectFileToMatch(modulePath,
/import { TestGuard2Guard } from '.\/test-guard2.guard'/))
.then(() => ng('build'));
}