當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。