本文整理汇总了TypeScript中fs-extra.mkdirs函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mkdirs函数的具体用法?TypeScript mkdirs怎么用?TypeScript mkdirs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkdirs函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: prepareDiffFile
async function prepareDiffFile(
rs: RepositorySession,
file: DiffFile
): Promise<string> {
if (file.sha === "UNSTAGED") {
// use file in the repository directly
return path.join(rs.repoPath, file.path);
}
let absPath: string;
if (file.sha === "STAGED") {
const fileName = path.basename(file.path);
const tempFileName = `STAGED-${randomName(6)}-${fileName}`;
// TODO: check file name conflict
absPath = path.join(rs.tempdir, tempFileName);
} else {
// TODO: shorten path
absPath = path.join(rs.tempdir, file.sha, file.path);
const parentDir = path.dirname(absPath);
if (!(await fs.pathExists(parentDir))) {
await fs.mkdirs(parentDir);
}
}
if (await fs.pathExists(absPath)) {
return absPath;
}
await git.saveTo(rs.repoPath, file.path, file.sha, absPath);
return absPath;
}
示例2: setupProject
async function setupProject() {
await fs.remove(testModulePath);
await fs.mkdirs(testModulePath);
await fs.writeFile(path.resolve(testModulePath, 'package.json'), await fs.readFile(path.resolve(__dirname, '../fixture/native_app/package.json'), 'utf8'));
await yarnOrNpmSpawn(hasYarn() ? [] : ['install'], {
cwd: testModulePath,
stdio: process.platform === 'win32' ? 'inherit' : 'pipe',
});
}
示例3: asyncOra
await asyncOra('Initializing Project Directory', async (initSpinner) => {
d('creating directory:', dir);
await fs.mkdirs(dir);
const files = await fs.readdir(dir);
if (files.length !== 0) {
d('found', files.length, 'files in the directory. warning the user');
initSpinner.stop(logSymbols.warning);
throw `The specified path: "${dir}" is not empty, do you wish to continue?`;
}
});
示例4: function
http.createServer(app).listen(app.get('port'), function () {
fs.mkdirs(path.join(__dirname, '/config'));
fs.mkdirs(path.join(__dirname, '/views'));
fs.copy(path.join(__dirname + '/../server/config'), path.join(__dirname, '/config') , function (err) {
if (err) return console.error(err);
new InitialData(db).verifyData();
});
fs.copy(path.join(__dirname + '/../server/views'), path.join(__dirname, '/views') , function (err) {
if (err) return console.error(err);
console.log("views copied!")
});
//livereload(app, { watchDir: path.join(__dirname, '../build')});
console.log("Express server listening on port " + app.get('port'));
console.log("Service file from ..." + path.join(__dirname, '/build'));
});
示例5: asyncOra
await asyncOra('Copying Starter Files', async () => {
const tmplPath = path.resolve(__dirname, '../../../tmpl');
d('creating directory:', path.resolve(dir, 'src'));
await fs.mkdirs(path.resolve(dir, 'src'));
const rootFiles = ['_gitignore'];
if (copyCIFiles) rootFiles.push(...['_travis.yml', '_appveyor.yml']);
const srcFiles = ['index.js', 'index.html'];
for (const file of rootFiles) {
await copy(path.resolve(tmplPath, file), path.resolve(dir, file.replace(/^_/, '.')));
}
for (const file of srcFiles) {
await copy(path.resolve(tmplPath, file), path.resolve(dir, 'src', file));
}
});
示例6: Boolean
Object.keys(availableLanguages).map(async (availableLanguage) => {
const messagesJsonStr = await transifex.translationInstanceMethodAsync(
projectSlug,
resourceSlug,
availableLanguage,
{mode: 'onlytranslated'}
)
const messagesJson: Messages = JSON.parse(messagesJsonStr)
const sortedMessagesJson = Object.keys(messagesJson)
.filter((key) => Boolean(R.path([key, 'message'], messagesJson)))
.sort()
.reduce((obj: Messages, key) => {
// trim message
if (messagesJson[key].message) {
messagesJson[key].message = messagesJson[key].message.trim()
}
return {
...obj,
[key]: messagesJson[key]
}
}, {})
let mappedLanguage = ''
switch (availableLanguage) {
case 'nb_NO':
mappedLanguage = 'nb'
break
default:
mappedLanguage = availableLanguage
}
await fs.mkdirs(path.join(localesPath, mappedLanguage))
await fs.outputJson(
path.join(localesPath, mappedLanguage, 'messages.json'),
sortedMessagesJson,
{spaces: 2}
)
console.log(`"${mappedLanguage}" is generated`)
})
示例7: beforeEach
beforeEach(async () => {
makeStub.returns(fakeMake('darwin'));
const dryPath = path.resolve(dir, 'out', 'publish-dry-run');
await fs.mkdirs(dryPath);
await fs.writeFile(path.resolve(dryPath, 'hash.json'), 'test');
await publish({
dir,
interactive: false,
dryRun: true,
});
expect(await fs.pathExists(path.resolve(dryPath, 'hash.json'))).to.equal(false, 'previous hashes should be erased');
const backupDir = path.resolve(dir, 'out', 'backup');
await fs.move(dryPath, backupDir);
makeStub.returns(fakeMake('win32'));
await publish({
dir,
interactive: false,
dryRun: true,
});
for (const backedUp of await fs.readdir(backupDir)) {
await fs.copy(path.resolve(backupDir, backedUp), path.resolve(dryPath, backedUp));
}
});
示例8:
}
);
fs.copySync(src, dest,
{
overwrite: true,
preserveTimestamps: true,
filter: /.*/
}
);
fs.createFile(file).then(() => {
// stub
});
fs.createFile(file, errorCallback);
fs.createFileSync(file);
fs.mkdirs(dir).then(() => {
// stub
});
fs.mkdirp(dir).then(() => {
// stub
});
fs.mkdirs(dir, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirp(dir, errorCallback);
fs.mkdirpSync(dir);
fs.outputFile(file, data).then(() => {
// stub
});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);
示例9:
clobber: true,
preserveTimestamps: true,
filter: (src: string) => { return false; }
}
);
fs.copySync(src, dest,
{
clobber: true,
preserveTimestamps: true,
filter: /.*/
}
);
fs.createFile(file, errorCallback);
fs.createFileSync(file);
fs.mkdirs(dir, errorCallback);
fs.mkdirs(dir, {}, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirsSync(dir, {});
fs.mkdirp(dir, errorCallback);
fs.mkdirp(dir, {}, errorCallback);
fs.mkdirpSync(dir);
fs.mkdirpSync(dir, {});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);
fs.outputJson(file, data, errorCallback);
fs.outputJSON(file, data, errorCallback);
fs.outputJsonSync(file, data);
fs.outputJSONSync(file, data);