当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs-extra.remove函数代码示例

本文整理汇总了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'),
   });
 });
开发者ID:jangocheng,项目名称:electron-forge,代码行数:6,代码来源:api_spec_slow.ts

示例2: async

 const ensureTestDirIsNonexistent = async () => {
   dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}`);
   dirID += 1;
   await fs.remove(dir);
 };
开发者ID:jangocheng,项目名称:electron-forge,代码行数:5,代码来源:api_spec_slow.ts

示例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);
开发者ID:danilobjr,项目名称:DefinitelyTyped,代码行数:31,代码来源:fs-extra-tests.ts

示例4: beforeEach

 beforeEach(() => Promise.all([
     fs.remove(tmpDir),
     fs.copy(fixtureFile1, editorFile1),
     fs.copy(fixtureFile2, editorFile2)
 ]));
开发者ID:sleistner,项目名称:vscode-fileutils,代码行数:5,代码来源:MoveFileCommand.test.ts

示例5: remove

 cb => remove(assetsDir, cb),
开发者ID:julianlam,项目名称:nodebb-plugin-emoji,代码行数:1,代码来源:build.ts

示例6:

 ['lib', 'node_modules', 'static'].forEach(folder => {
   let folderPath = path.join('.', name, folder);
   if (fs.existsSync(folderPath)) {
     fs.remove(folderPath);
   }
 });
开发者ID:ellisonbg,项目名称:jupyterlab,代码行数:6,代码来源:create-theme.ts

示例7:

gulp.task('clean.test', (done) => fse.remove(PATHS.dest.test, done));
开发者ID:JayKan,项目名称:angular2-change-detection,代码行数:1,代码来源:gulpfile.ts

示例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);
  });
开发者ID:Meistercoach83,项目名称:sfw,代码行数:66,代码来源:generate-thumbnails.ts


注:本文中的fs-extra.remove函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。