本文整理汇总了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);
});