本文整理汇总了TypeScript中mkdirp.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createDirectory
export default async function createDirectory(args: ActionArgs) {
const directoryName = args.nodes.text().trim()
if (!directoryName) {
throw new Error('empty directory name given')
}
args.formatter.name(`create directory ${chalk.cyan(directoryName)}`)
const fullPath = path.join(args.configuration.workspace, directoryName)
await mkdirp(fullPath)
}
示例2: function
zipfile.on("entry", function (entry: any) {
let desiredPath = path.join(targetDirectory, entry.fileName);
//let desiredPath = targetDirectory + entry.fileName;
if (/\/$/.test(entry.fileName)) {
// directory file names end with '/'
mkdirp(desiredPath, function (err: any) {
if (err) throw err;
zipfile.readEntry();
});
} else {
// file entry
zipfile.openReadStream(entry, function (err: any, readStream: any) {
if (err) throw err;
// ensure parent directory exists
mkdirp(path.dirname(desiredPath), function (err: any) {
if (err) throw err;
readStream.pipe(fs.createWriteStream(desiredPath));
readStream.on("end", function () {
zipfile.readEntry();
resolve();
});
});
});
}
});
示例3: moment
let postImageFromClipboardDisposable = vscode.commands.registerCommand('extension.writeCnblog.postImageFromClipboard', () => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showErrorMessage("没有打开编辑窗口");
return;
}
let folderPath = path.dirname(editor.document.fileName);
let ext = path.extname(editor.document.fileName);
let fileName = path.basename(editor.document.fileName,ext);
let fileNameWithoutExt = moment().format("YYYYMMDDHHmmss") + ".png";
let imagePath = path.join(folderPath,"Images",fileName,fileNameWithoutExt);
let dir = path.dirname(imagePath);
// create a directory if doesn't exist
mkdirp(dir,(err: string)=> {
if (err) { vscode.window.showErrorMessage(err) ; }
else {
saveClipboardImageToFileAndGetPath(imagePath, (imagePath, imagePathReturnByScript) => {
if (!imagePathReturnByScript) { return; }
if (imagePathReturnByScript === 'no image') {
vscode.window.showErrorMessage('There is not a image in clipboard.');
return;
}
//上传图片
pushImage(imagePath,editor);
});
}
});
});
示例4: Promise
await new Promise((resolve, reject) =>
mkdirp(parentDir, err => {
if (err) {
reject(err);
} else {
resolve();
}
})
示例5: Promise
return new Promise((resolve, reject) => {
mkdirp(this.getProjectDir(), (err) => {
if (err) {
resolve(false);
} else {
resolve(true);
}
});
});
示例6: Promise
return new Promise((resolve, reject) => {
mkdirp(dir, err => {
if (err) {
reject(err);
}
else {
resolve();
}
});
});
示例7: create
create(name: string, data: any, layout: string): void {
Mkdirp(this.dest, err => {
if (err) {
console.error(err);
}
let filename: string = name === 'index' ? 'index.html' : `${name}-example.html`;
fs.writeFileSync(`${this.dest}/${filename}`, this.compile(data, layout), 'utf8');
});
}
示例8: mkdirp
return p.then(() => {
var deferred = q.defer();
mkdirp(__dirname + savePath, function (err) {
if (err) deferred.reject(err);
page.render(savePath + "/" + saveFilename, { format: 'jpg', quality: '60' }).then(() => {
console.log("Generated screenshot", url, savePath, saveFilename);
deferred.resolve();
page.close();
});
});
return deferred.promise;
});