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


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

本文整理汇总了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;未经允许,请勿转载。