本文整理匯總了TypeScript中fs-extra.remove函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript remove函數的具體用法?TypeScript remove怎麽用?TypeScript remove使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了remove函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: after
after(async () => {
await fs.remove(dir);
execSync('npm unlink', {
cwd: path.resolve(__dirname, '../fixture/custom_init'),
});
});
示例2: async
const ensureTestDirIsNonexistent = async () => {
dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}`);
dirID += 1;
await fs.remove(dir);
};
示例3:
fs.readJson(file).then(() => {
// stub
});
fs.readJson(file, readOptions).then(() => {
// stub
});
fs.readJson(file, (error: Error, jsonObject: any) => { });
fs.readJson(file, readOptions, (error: Error, jsonObject: any) => { });
fs.readJSON(file, (error: Error, jsonObject: any) => { });
fs.readJSON(file, readOptions, (error: Error, jsonObject: any) => { });
fs.readJsonSync(file, readOptions);
fs.readJSONSync(file, readOptions);
fs.remove(dir, errorCallback);
fs.remove(dir).then(() => {
// stub
});
fs.removeSync(dir);
fs.writeJson(file, object).then(() => {
// stub
});
fs.writeJSON(file, object).then(() => {
// stub
});
fs.writeJson(file, object, errorCallback);
fs.writeJson(file, object, writeOptions, errorCallback);
fs.writeJSON(file, object, errorCallback);
fs.writeJSON(file, object, writeOptions, errorCallback);
示例4: beforeEach
beforeEach(() => Promise.all([
fs.remove(tmpDir),
fs.copy(fixtureFile1, editorFile1),
fs.copy(fixtureFile2, editorFile2)
]));
示例5: remove
cb => remove(assetsDir, cb),
示例6:
['lib', 'node_modules', 'static'].forEach(folder => {
let folderPath = path.join('.', name, folder);
if (fs.existsSync(folderPath)) {
fs.remove(folderPath);
}
});
示例7:
gulp.task('clean.test', (done) => fse.remove(PATHS.dest.test, done));
示例8: Storage
.storage.object().onFinalize(async object => {
const gcs = new Storage();
const bucket = gcs.bucket(object.bucket);
const filePath = object.name;
const contentType = object.contentType;
const bucketDir = dirname(filePath);
if (!contentType.startsWith('image/')) {
console.log('This is not an image');
return null;
}
const fileName = basename(filePath);
if (fileName.startsWith('thumb_')) {
console.log('Already a Thumbnail.');
return null;
}
const workingDir = join(os.tmpdir(), 'thumbs');
const tmpFilePath = join(workingDir, fileName);
const metadata = {
contentType: contentType,
};
await fs.ensureDir(workingDir);
await bucket.file(filePath).download({
destination: tmpFilePath
});
const uploadPromises = THUMBNAILSIZES.map(async thumbDef => {
const thumbFileName = `thumb_${fileName}_${thumbDef.name}.${contentType.substring(contentType.indexOf('/') + 1)}`;
const thumbFilePath = join(workingDir, thumbFileName);
const fileTransform = sharp(tmpFilePath);
if (object.contentType === 'image/jpeg') {
fileTransform.jpeg({ quality: thumbDef.quality });
}
if (object.contentType === 'image/png') {
fileTransform.png({ quality: thumbDef.quality });
}
if (thumbDef.width && thumbDef.height) {
console.log(thumbDef);
fileTransform.resize({ width: thumbDef.width, height: thumbDef.height });
} else if (!thumbDef.width && thumbDef.height) {
fileTransform.resize({ height: thumbDef.height });
} else {
fileTransform.resize(thumbDef.width);
}
await fileTransform.toFile(thumbFilePath);
return bucket.upload(thumbFilePath, {
destination: join(bucketDir, thumbFileName),
metadata: metadata
});
});
await Promise.all(uploadPromises);
return fs.remove(tmpFilePath);
});