• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fs-extra-promise.removeAsync函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中fs-extra-promise.removeAsync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript removeAsync函数的具体用法?TypeScript removeAsync怎么用?TypeScript removeAsync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了removeAsync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: build

export default async function build(options: BuildOptions) {
  // clean up
  if (options.production) {
    await removeAsync(project.ws.distReleaseDir);
  } else {
    await removeAsync(project.ws.distDir);
  }

  // prepare i18n
  if (project.ws.i18n) {
    await compileI18n();
    info('...build translations');
  }

  // build
  switch (project.ws.type) {
    case TYPE.NODE:
      await compileAsync(getNodeBuildConfig(), 'build');
      break;
    case TYPE.ELECTRON:
      if (options.production) {
        await compileAsync(getElectronReleaseConfig(), 'build -p');
      } else {
        await compileAsync(getElectronBuildConfig(), 'build');
      }
      break;
    case TYPE.SPA:
      if (options.production) {
        await compileAsync(getSpaReleaseConfig(), 'build -p');
      } else {
        await compileAsync(getSpaBuildConfig(), 'build');
      }
      break;
    case TYPE.BROWSER:
      if (options.production) {
        await compileAsync(getBrowserReleaseConfig(), 'build -p');
      } else {
        await compileAsync(getBrowserBuildConfig(), 'build');
      }
      break;
  }

  // typings (will be only genereated, if typings are set in package.json)
  if (options.production) {
    await generateTypings(project.ws.distReleaseDir);
  } else if (project.ws.type === TYPE.NODE) {
    await generateTypings(project.ws.distDir);
  }
}
开发者ID:otbe,项目名称:ws,代码行数:49,代码来源:build.ts


示例2: watch

export default async function watch() {
  await removeAsync(project.ws.distDir);

  const port = await findAsync({
    startingPort: 35729
  });
  const livereloadServer = livereload.createServer({ port });
  const onChangeSuccess = (stats) => info(`Finished build at ${cyan(moment(stats.endTime).format('HH:mm:ss'))}.`);
  switch (project.ws.type) {
    case TYPE.NODE:
      await watchAsync(livereloadServer, nodeOptions, onChangeSuccess);
      break;
    case TYPE.SPA:
      if (project.ws.i18n) {
        await watchAsync(livereloadServer, createLocaleSpecificOptions(spaOptions, project.ws.i18n.locales[0]), onChangeSuccess);
      } else {
        await watchAsync(livereloadServer, spaOptions, onChangeSuccess);
      }
      break;
    case TYPE.BROWSER:
      if (project.ws.i18n) {
        await watchAsync(livereloadServer, createLocaleSpecificOptions(browserOptions, project.ws.i18n.locales[0]), onChangeSuccess);
      } else {
        await watchAsync(livereloadServer, browserOptions, onChangeSuccess);
      }
      break;
  }

  info('Finished initial build.');

  const middlewares = [
    livereloadMiddleware()
  ];
  await listenAsync(middlewares);
};
开发者ID:Mercateo,项目名称:typedocs,代码行数:35,代码来源:watch.ts


示例3: i18nCompile

export default async function i18nCompile() {
  const features = project.ws.i18n.features || [ '' ];
  const locales = project.ws.i18n.locales;
  const localesAndLanguages = concatLanguages(locales);

  const readPromises: Promise<Translation>[] = [];
  features.forEach(feature => localesAndLanguages.forEach(localeOrLanguage => {
    readPromises.push(readTranslation(localeOrLanguage, feature));
  }));
  const translations: Translation[] = await Promise.all(readPromises);

  const groupedTranslations: GroupedTranslation[] = locales.map(locale => ({
    locale,
    translations: translations.filter(translation => isMatchingLocaleOrLanguage(translation.locale, locale))
  }));

  const mergedTranslations: Translation[] = groupedTranslations.map(({ locale, translations }) => ({
    locale,
    data: translations.reverse().reduce((acc, translation) => Object.assign(acc, translation.data), {} as TranslationMap)
  }));

  const parsedTranslations: ParsedTranslation[] = mergedTranslations.map(translation => {
    const asts = {};
    Object.keys(translation.data).forEach(key => {
      const ast = parser.parse(translation.data[key]);
      asts[key] = ast;
    });
    return Object.assign({ asts }, translation);
  });

  await removeAsync(join(project.ws.srcDir, project.ws.i18n.dir));
  await Promise.all(parsedTranslations.map(writeTranslation));
  await writeIndexTranslation(parsedTranslations);
};
开发者ID:Mercateo,项目名称:typedocs,代码行数:34,代码来源:i18n-compile.ts


示例4: generate

async function generate(rootDir: string) {

    const pbconfigPath = path.join(rootDir, 'pbconfig.json');
    if (!(await fs.existsAsync(pbconfigPath))) {
        if (await fs.existsAsync(path.join(rootDir, 'protobuf'))) {
            const pbconfigPath = path.join(rootDir, 'protobuf', 'pbconfig.json')
            if (!await (fs.existsAsync(pbconfigPath))) {
                await fs.writeFileAsync(pbconfigPath, pbconfigContent, 'utf-8');
            }
            await generate(path.join(rootDir, 'protobuf'));
        }
        else {
            throw '请首先执行 pb-egret add 命令'
        }
        return;
    }
    const pbconfig: ProtobufConfig = await fs.readJSONAsync(path.join(rootDir, 'pbconfig.json'));
    const tempfile = path.join(os.tmpdir(), 'pbegret', 'temp.js');
    await fs.mkdirpAsync(path.dirname(tempfile));
    const output = path.join(rootDir, pbconfig.outputFile);
    const dirname = path.dirname(output);
    await fs.mkdirpAsync(dirname);
    const protoRoot = path.join(rootDir, pbconfig.sourceRoot);
    const fileList = await fs.readdirAsync(protoRoot);
    const protoList = fileList.filter(item => path.extname(item) === '.proto')
    if (protoList.length == 0) {
        throw ' protofile 文件夹中不存在 .proto 文件'
    }
    await Promise.all(protoList.map(async (protofile) => {
        const content = await fs.readFileAsync(path.join(protoRoot, protofile), 'utf-8')
        if (content.indexOf('package') == -1) {
            throw `${protofile} 中必须包含 package 字段`
        }
    }))




    const args = ['-t', 'static', '-p', protoRoot, protoList.join(" "), '-o', tempfile]
    if (pbconfig.options['no-create']) {
        args.unshift('--no-create');
    }
    if (pbconfig.options['no-verify']) {
        args.unshift('--no-verify');
    }
    await shell('pbjs', args);
    let pbjsResult = await fs.readFileAsync(tempfile, 'utf-8');
    pbjsResult = 'var $protobuf = window.protobuf;\n$protobuf.roots.default=window;\n' + pbjsResult;
    await fs.writeFileAsync(output, pbjsResult, 'utf-8');
    const minjs = UglifyJS.minify(pbjsResult);
    await fs.writeFileAsync(output.replace('.js', '.min.js'), minjs.code, 'utf-8');
    await shell('pbts', ['--main', output, '-o', tempfile]);
    let pbtsResult = await fs.readFileAsync(tempfile, 'utf-8');
    pbtsResult = pbtsResult.replace(/\$protobuf/gi, "protobuf").replace(/export namespace/gi, 'declare namespace');
    pbtsResult = 'type Long = protobuf.Long;\n' + pbtsResult;
    await fs.writeFileAsync(output.replace(".js", ".d.ts"), pbtsResult, 'utf-8');
    await fs.removeAsync(tempfile);

}
开发者ID:bestdpf,项目名称:protobuf-egret,代码行数:59,代码来源:index.ts


示例5: delete_file

export async function delete_file(file_path: string): Promise<void>{
	await lock.acquire();
	try{
		await fs.removeAsync(file_path);
	}
	finally{
		lock.release();
	}
}
开发者ID:BelaPlatform,项目名称:Bela,代码行数:9,代码来源:FileManager.ts


示例6: build

export default async function build(options) {
  switch (project.ws.type) {
    case TYPE.NODE:
      await removeAsync(project.ws.distDir);
      await compileAsync(nodeOptions);
      break;
    case TYPE.SPA:
      if (options.production) {
        await removeAsync(project.ws.distReleaseDir);
        if (project.ws.i18n) {
          for (const locale of project.ws.i18n.locales) {
            info(`...for locale ${locale}.`);
            await compileAsync(createLocaleSpecificOptions(spaReleaseOptions, locale));
          }
        } else {
          await compileAsync(spaReleaseOptions);
        }
      } else {
        await removeAsync(project.ws.distDir);
        if (project.ws.i18n) {
          await compileAsync(createLocaleSpecificOptions(spaOptions, project.ws.i18n.locales[0]));
        } else {
          await compileAsync(spaOptions);
        }
      }
      break;
    case TYPE.BROWSER:
      await removeAsync(project.ws.distDir);
      if (project.ws.i18n) {
        for (const locale of project.ws.i18n.locales) {
          info(`...for locale ${locale}.`);
          await compileAsync(createLocaleSpecificOptions(browserOptions, locale));
          await compileAsync(createLocaleSpecificOptions(browserReleaseOptions, locale));
        }
        info(`...with all locales.`);
      }
      // even when we use locales, we create a default build containing *all* translations
      // users can select a locale with `window.process = { env: { LOCALE: 'en_GB' } };`, before they load
      // our component (this is mostly for users without build tools)
      await compileAsync(browserOptions);
      await compileAsync(browserReleaseOptions);
      break;
  }
};
开发者ID:Mercateo,项目名称:typedocs,代码行数:44,代码来源:build.ts


示例7: i18nImport

export default async function i18nImport() {
  const features = project.ws.i18n.features || [ '' ];
  const locales = project.ws.i18n.locales;
  const localesAndLanguages = concatLanguages(locales);

  await removeAsync(project.ws.i18n.dir);
  const importPromises = [];
  features.forEach(feature => localesAndLanguages.forEach(localeOrLanguage => {
    importPromises.push(importTranslation(localeOrLanguage, feature));
  }));

  await Promise.all(importPromises);
};
开发者ID:Mercateo,项目名称:typedocs,代码行数:13,代码来源:i18n-import.ts


示例8: compile

export async function compile() {
  // at this place we know i18n config is set, no need for null checks
  const i18n = project.ws.i18n as I18nConfig;
  const parsedTranslations: Array<ParsedTranslation> = await getTranslations();

  await removeAsync(i18n.distDir);
  await Promise.all(
    parsedTranslations.map((parsedTranslation) =>
      writeTranslation(parsedTranslations[0], parsedTranslation)
    )
  );

  if (project.ws.entryExtension !== 'js') {
    await writeDeclaration(parsedTranslations);
  }
}
开发者ID:Mercateo,项目名称:ws,代码行数:16,代码来源:compile.ts


示例9: i18nImport

export default async function i18nImport() {
  // at this place we know i18n config is set, no need for null checks
  const i18n = project.ws.i18n as I18nConfig;

  const features = i18n.features || [''];
  const locales = i18n.locales;
  const localesAndLanguages = concatLanguages(locales);

  await removeAsync(i18n.dir);
  const importPromises: Array<Promise<void>> = [];
  features.forEach(feature =>
    localesAndLanguages.forEach(localeOrLanguage => {
      importPromises.push(importTranslation(localeOrLanguage, feature, i18n));
    })
  );

  await Promise.all(importPromises);
}
开发者ID:otbe,项目名称:ws,代码行数:18,代码来源:i18n-import.ts


示例10: unit

export default async function unit(options) {
  const unitEntry = `./${project.ws.testsDir}/unit.${project.ws.entryExtension}`;
  const hasUnitTests = await existsAsync(unitEntry);
  if (!hasUnitTests) {
    warn(`${yellow('warn!')} You tried to run unit tests, but ${yellow(unitEntry)} doesn't exist.`);
    return;
  }

  await removeAsync(project.ws.distTestsDir);

  let exitCode;
  switch (project.ws.type) {
    case TYPE.NODE:
      await compileAsync(nodeUnitOptions);
      const files = [
        path.join(nodeUnitOptions.output.path, nodeUnitOptions.output.filename)
      ];
      exitCode = await mochaTestAsync(files);
      break;
    case TYPE.SPA:
      if (project.ws.i18n) {
        await compileAsync(createLocaleSpecificOptions(spaUnitOptions, project.ws.i18n.locales[0]));
      } else {
        await compileAsync(spaUnitOptions);
      }
      exitCode = await karmaTestAsync(options);
      break;
    case TYPE.BROWSER:
      if (project.ws.i18n) {
        await compileAsync(createLocaleSpecificOptions(browserUnitOptions, project.ws.i18n.locales[0]));
      } else {
        await compileAsync(browserUnitOptions);
      }
      exitCode = await karmaTestAsync(options);
      break;
  }

  if (exitCode !== 0) {
    throw `${cyan('unit')} failed.`;
  }
};
开发者ID:Mercateo,项目名称:typedocs,代码行数:41,代码来源:unit.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra-promise.writeFileAsync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra-promise.readJsonSync函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap