本文整理匯總了TypeScript中mkdirp類的典型用法代碼示例。如果您正苦於以下問題:TypeScript mkdirp類的具體用法?TypeScript mkdirp怎麽用?TypeScript mkdirp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了mkdirp類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: mkdirp
http.get(file, (response) => {
mkdirp(path.dirname(outputPath), (err: Error) => {
const localFile = fs.createWriteStream(outputPath);
localFile.on("finish", () => { progress++; exportWindow.setProgressBar(progress / progressMax); cb(null); });
response.pipe(localFile);
});
}).on("error", cb);
示例2: mkdirp
zipFile.on("entry", (entry: any) => {
if (entry.fileName.indexOf(rootFolderName) !== 0) throw new Error(`Found file outside of root folder: ${entry.fileName} (${rootFolderName})`);
const filename = path.join(downloadPath, entry.fileName.replace(rootFolderName, ""));
if (/\/$/.test(entry.fileName)) {
mkdirp(filename, (err) => {
if (err != null) throw err;
progress++;
onProgress(progress / progressMax);
zipFile.readEntry();
});
} else {
zipFile.openReadStream(entry, (err: Error, readStream: NodeJS.ReadableStream) => {
if (err) throw err;
mkdirp(path.dirname(filename), (err: Error) => {
if (err) throw err;
readStream.pipe(fs.createWriteStream(filename));
readStream.on("end", () => {
progress++;
onProgress(progress / progressMax);
zipFile.readEntry();
});
});
});
}
});
示例3: execute
return function execute() {
const example = deps.params.example || 'counter';
const dir = deps.pwd;
function streamFrintExampleToDir() {
request('https://codeload.github.com/frintjs/frint/tar.gz/master')
.on('error', deps.console.error)
.pipe(tar.x({
C: dir,
filter: path => path.indexOf(`frint-master/examples/${example}/`) === 0,
strip: 3,
}))
.on('error', deps.console.error)
.on('finish', () => deps.console.log('Done!'));
}
deps.console.log('Initializing...');
mkdirp(dir, function mkdirpCallback(error) {
if (error) {
deps.console.error(error);
return;
}
streamFrintExampleToDir();
});
};
示例4: mkdirp
return new Promise<any>(function (resolve, reject) {
mkdirp(path, function (err: Error, made: string) {
if (err) reject(err);
resolve(made);
});
});
示例5: mkdirp
zipFile.on("entry", (entry: any) => {
if (entry.fileName.indexOf(rootFolderName) !== 0) throw new Error(`Found file outside of root folder: ${entry.fileName} (${rootFolderName})`);
const filename = path.join(settings.corePath, entry.fileName.replace(rootFolderName, ""));
if (/\/$/.test(entry.fileName)) {
mkdirp(filename, (err) => {
if (err != null) throw err;
entriesProcessed++;
splashScreen.setProgressValue(zipFile.entryCount + entriesProcessed);
zipFile.readEntry();
});
} else {
zipFile.openReadStream(entry, (err: Error, readStream: NodeJS.ReadableStream) => {
if (err) throw err;
mkdirp(path.dirname(filename), (err: Error) => {
if (err) throw err;
readStream.pipe(fs.createWriteStream(filename));
readStream.on("end", () => {
entriesProcessed++;
splashScreen.setProgressValue(zipFile.entryCount + entriesProcessed);
zipFile.readEntry();
});
});
});
}
});
示例6: Promise
return new Promise((resolve, reject) => {
mkdirp(targetDirectory, error => {
if (error) {
return reject(error);
}
resolve();
});
});
示例7: Promise
return new Promise((resolve, reject) => {
mkdirp(path, (err) => {
if (err) {
reject(err)
} else {
resolve(path)
}
})
})
示例8: mkdirp
server.data.assets.acquire(assetId, null, (err: Error, asset: SupCore.Data.Base.Asset) => {
const folderPath = `${buildPath}/assets/${server.data.entries.getStoragePathFromId(assetId)}`;
mkdirp(folderPath, (err) => {
asset.save(folderPath, (err) => {
server.data.assets.release(assetId, null);
cb();
});
});
});
示例9: Promise
return new Promise((resolve, reject) => {
mkdirp(ctx.outputDir, function mkdirpCallback(error) {
if (error) {
reject(error);
return;
}
resolve(ctx);
});
});
示例10: checkPathAuthorization
checkPathAuthorization(folderPath, (normalizedFolderPath, authorization) => {
if (authorization !== "readWrite") {
callback(new Error(`Access to "${normalizedFolderPath}" hasn't been authorized for read/write.`));
return;
}
fsMkdirp(normalizedFolderPath, callback);
});