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