本文整理汇总了TypeScript中fs-extra.mkdir函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mkdir函数的具体用法?TypeScript mkdir怎么用?TypeScript mkdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkdir函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: prepareTargetDir
async function prepareTargetDir(
bundle: boolean,
separateBuildDir: boolean
): Promise<TargetPaths> {
let targetDir = path.join(os.tmpdir(), `vscode-firefox-debug-test-${uuid.v4()}`);
await fs.mkdir(targetDir);
let scriptTags = bundle ? ['bundle.js'] : ['f.min.js', 'g.min.js'];
if (!separateBuildDir) {
await sourceMapUtil.copyFiles(TESTDATA_PATH, targetDir, ['index.html', 'f.js', 'g.js']);
await sourceMapUtil.injectScriptTags(targetDir, scriptTags);
return { targetDir, srcDir: targetDir, buildDir: targetDir };
} else {
let srcDir = path.join(targetDir, 'src');
await fs.mkdir(srcDir);
let buildDir = path.join(targetDir, 'build');
await fs.mkdir(buildDir);
await sourceMapUtil.copyFiles(TESTDATA_PATH, srcDir, ['f.js', 'g.js']);
await sourceMapUtil.copyFiles(TESTDATA_PATH, buildDir, ['index.html']);
await sourceMapUtil.injectScriptTags(buildDir, scriptTags);
return { targetDir, srcDir, buildDir };
}
}
示例2: before
before(async () => {
await ensureTestDirIsNonexistent();
await fs.mkdir(dir);
execSync(`${nodeInstaller} init -y`, {
cwd: dir,
});
});
示例3: Promise
return new Promise((resolve, reject) => {
fs.mkdir(p, err => {
if (!err) {
locks[p] = 1
fs.writeFile(pidPath, process.pid.toString(), resolve)
return
}
if (err.code !== 'EEXIST') return reject(err)
lockActive(pidPath)
.then(active => {
if (!active)
return unlock(p)
.then(resolve as any)
.catch(reject)
if (timeout <= 0) throw new Error(`${p} is locked`)
debug(`locking ${p} ${timeout / 1000}s...`)
wait(1000).then(() =>
lock(p, timeout - 1000)
.then(resolve)
.catch(reject),
)
})
.catch(reject)
})
})
示例4: getNewPath
getNewPath('Enter a new folder name', data.cwd, newPath => {
fs.mkdir(newPath, err => {
if (codeFileNav.checkError(err)) { return; }
codeFileNav.showFileList();
});
});
示例5: checkEnv
async checkEnv () {
this.emit('progress', 'checkJava')
await this._checkJava()
this.emit('progress', 'cleanNatives')
await this._cleanNatives()
this._arguments.push(`-Djava.library.path=${this._nativesPath}`)
this.emit('progress', 'resolveLibraries')
await this._setupLibraries()
this.emit('progress', 'resolveNatives')
await fs.mkdir(this._nativesPath)
await this._setupNatives()
if (this._missingLibrary.length !== 0) {
this.emit('missing_all', this._missingLibrary)
let err = new Error('missing library')
err['missing'] = this._missingLibrary
err['launcher'] = this
throw err
}
await fs.ensureDir(this._gameDirectory)
this.emit('progress', 'mergeArguments')
this._arguments.push(this.opts.json['mainClass'])
this._mcArguments()
this.emit('progress', 'envOK')
}
示例6: reject
return new Promise<void>((resolve, reject) => {
Fs.mkdir(directoryPath, err => {
if (err && err.code !== 'EEXIST') {
reject(err)
return
}
resolve()
})
})
示例7: it
it('should return an absolute path when run inside a working directory', async () => {
const result = await getTopLevelWorkingDirectory(repository!.path)
expect(result).to.equal(repository!.path)
const subdirPath = path.join(repository!.path, 'subdir')
await FSE.mkdir(subdirPath)
const subDirResult = await getTopLevelWorkingDirectory(repository!.path)
expect(subDirResult).to.equal(repository!.path)
})
示例8:
return new this.$q<Models.IFolder>((resolve, reject) => {
var folderPath = nodeJsPath.join(folder.path, name);
nodeFs.mkdir(folderPath, (err) => {
if (err) {
reject(err);
}
else {
resolve(new Models.NodeFolder(folderPath, folder));
}
});
});
示例9: Before
Before(async function() {
this.rootDir = path.join(process.cwd(), 'tmp')
let rootDirExists = false
try {
await fs.stat(this.rootDir)
rootDirExists = true
} catch (e) {
// nothing to do here
}
if (rootDirExists) {
rimraf.sync(this.rootDir)
}
await fs.mkdir(this.rootDir)
})
示例10: logFile
/**
* Determine the location of the log file based on the operating system
* and return as an absolute string from os.homedir()
*
* @returns {string} Path to log file
**/
async function logFile () {
const homeDir : string = os.homedir();
const linuxDir : string = `/.config/mcopy/`;
const macDir : string = `/Library/Logs/mcopy/`;
const winDir : string = `/AppData/Roaming/mcopy/`;
let logPath : string = path.join(homeDir, linuxDir);
let exists : boolean;
if (process.platform === 'darwin') {
logPath = path.join(homeDir, macDir);
} else if (process.platform === 'win32') {
logPath = path.join(homeDir, winDir);
}
exists = await fs.exists(logPath);
if (!exists) {
await fs.mkdir(logPath);
}
return path.join(logPath, 'mcopy.log');
}