當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript rimraf.sync函數代碼示例

本文整理匯總了TypeScript中rimraf.sync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript sync函數的具體用法?TypeScript sync怎麽用?TypeScript sync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sync函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: resolve

                resolve(memo);
                return;
            }
            Promise.cast(iter(arr.shift())).then((res: W) => {
                memo.push(res);
                next();
            }, reject);
        };
        next();
    });
}

// As soon as this module is loaded we clear the tscache
// This ensures that we compile all the typescript whenever we are restarted
try {
    rimraf.sync(cacheUtils.cacheDir);
    gruntGlobal.log.writeln('Cleared fast compile cache'.cyan);
}
catch (ex) {
    gruntGlobal.log.writeln('No existing fast compile cache'.cyan);
}

function pluginFn(grunt: IGrunt) {

    /////////////////////////////////////////////////////////////////////
    // The grunt task
    ////////////////////////////////////////////////////////////////////

    // Note: this function is called once for each target
    // so task + target options are a bit blurred inside this function
    grunt.registerMultiTask('ts', 'Compile TypeScript files', function () {
開發者ID:donaldpipowitch,項目名稱:grunt-ts,代碼行數:31,代碼來源:ts.ts

示例2: function

  run: function (serveTaskOptions: ServeTaskOptions, rebuildDoneCb: any) {
    const ui = this.ui;

    let webpackCompiler: any;
    const projectConfig = CliConfig.fromProject().config;
    const appConfig = projectConfig.apps[0];

    const outputPath = serveTaskOptions.outputPath || appConfig.outDir;
    if (this.project.root === outputPath) {
      throw new SilentError('Output path MUST not be project root directory!');
    }
    rimraf.sync(path.resolve(this.project.root, outputPath));

    const serveDefaults = {
      // default deployUrl to '' on serve to prevent the default from angular-cli.json
      deployUrl: ''
    };

    serveTaskOptions = Object.assign({}, serveDefaults, serveTaskOptions);

    let webpackConfig = new NgCliWebpackConfig(serveTaskOptions).config;

    // This allows for live reload of page when changes are made to repo.
    // https://webpack.github.io/docs/webpack-dev-server.html#inline-mode
    let entryPoints = [
      `webpack-dev-server/client?http://${serveTaskOptions.host}:${serveTaskOptions.port}/`
    ];
    if (serveTaskOptions.hmr) {
      const webpackHmrLink = 'https://webpack.github.io/docs/hot-module-replacement.html';
      ui.writeLine(oneLine`
        ${chalk.yellow('NOTICE')} Hot Module Replacement (HMR) is enabled for the dev server.
      `);
      ui.writeLine('  The project will still live reload when HMR is enabled,');
      ui.writeLine('  but to take advantage of HMR additional application code is required');
      ui.writeLine('  (not included in an Angular CLI project by default).');
      ui.writeLine(`  See ${chalk.blue(webpackHmrLink)}`);
      ui.writeLine('  for information on working with HMR for Webpack.');
      entryPoints.push('webpack/hot/dev-server');
      webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
      webpackConfig.plugins.push(new webpack.NamedModulesPlugin());
      if (serveTaskOptions.extractCss) {
        ui.writeLine(oneLine`
          ${chalk.yellow('NOTICE')} (HMR) does not allow for CSS hot reload when used
          together with '--extract-css'.
        `);
      }
    }
    if (!webpackConfig.entry.main) { webpackConfig.entry.main = []; }
    webpackConfig.entry.main.unshift(...entryPoints);
    webpackCompiler = webpack(webpackConfig);

    if (rebuildDoneCb) {
      webpackCompiler.plugin('done', rebuildDoneCb);
    }

    const statsConfig = getWebpackStatsConfig(serveTaskOptions.verbose);

    let proxyConfig = {};
    if (serveTaskOptions.proxyConfig) {
      const proxyPath = path.resolve(this.project.root, serveTaskOptions.proxyConfig);
      if (fs.existsSync(proxyPath)) {
        proxyConfig = require(proxyPath);
      } else {
        const message = 'Proxy config file ' + proxyPath + ' does not exist.';
        return Promise.reject(new SilentError(message));
      }
    }

    let sslKey: string = null;
    let sslCert: string = null;
    if (serveTaskOptions.ssl) {
      const keyPath = path.resolve(this.project.root, serveTaskOptions.sslKey);
      if (fs.existsSync(keyPath)) {
        sslKey = fs.readFileSync(keyPath, 'utf-8');
      }
      const certPath = path.resolve(this.project.root, serveTaskOptions.sslCert);
      if (fs.existsSync(certPath)) {
        sslCert = fs.readFileSync(certPath, 'utf-8');
      }
    }

    const webpackDevServerConfiguration: IWebpackDevServerConfigurationOptions = {
      contentBase: path.join(this.project.root, `./${appConfig.root}`),
      headers: { 'Access-Control-Allow-Origin': '*' },
      historyApiFallback: {
        index: `/${appConfig.index}`,
        disableDotRule: true,
        htmlAcceptHeaders: ['text/html', 'application/xhtml+xml']
      },
      stats: statsConfig,
      inline: true,
      proxy: proxyConfig,
      compress: serveTaskOptions.target === 'production',
      watchOptions: {
        poll: projectConfig.defaults && projectConfig.defaults.poll
      },
      https: serveTaskOptions.ssl
    };

    if (sslKey != null && sslCert != null) {
//.........這裏部分代碼省略.........
開發者ID:Percyman,項目名稱:angular-cli,代碼行數:101,代碼來源:serve.ts

示例3: cleanup

async function cleanup(modulePath) {
  debug('Cleaning up temporary files...')
  rimraf.sync(path.join(modulePath, 'node_production_modules'))
}
開發者ID:seffalabdelaziz,項目名稱:botpress,代碼行數:4,代碼來源:package.ts

示例4:

 outdatedDirs.forEach(outdatedDir => rimraf.sync(path.join(directory, outdatedDir)));
開發者ID:JoshuaKGoldberg,項目名稱:tslint,代碼行數:1,代碼來源:buildDocs.ts

示例5: afterAll

 afterAll(() => {
   rimraf.sync(out_dir);
 });
開發者ID:elgohr,項目名稱:webdriver-manager,代碼行數:3,代碼來源:chrome_driver_spec.ts

示例6: after

 after(() => {
     rimraf.sync(outputDirName);
 });
開發者ID:dssoft32,項目名稱:javascript-obfuscator,代碼行數:3,代碼來源:JavaScriptObfuscatorCLI.spec.ts

示例7: function

  run: function (serveTaskOptions: ServeTaskOptions, rebuildDoneCb: any) {
    const ui = this.ui;

    let webpackCompiler: any;
    const projectConfig = CliConfig.fromProject().config;
    const appConfig = getAppFromConfig(projectConfig.apps, serveTaskOptions.app);

    const outputPath = serveTaskOptions.outputPath || appConfig.outDir;
    if (this.project.root === outputPath) {
      throw new SilentError('Output path MUST not be project root directory!');
    }
    if (projectConfig.project && projectConfig.project.ejected) {
      throw new SilentError('An ejected project cannot use the build command anymore.');
    }
    rimraf.sync(path.resolve(this.project.root, outputPath));

    const serveDefaults = {
      // default deployUrl to '' on serve to prevent the default from .angular-cli.json
      deployUrl: ''
    };

    serveTaskOptions = Object.assign({}, serveDefaults, serveTaskOptions);

    let webpackConfig = new NgCliWebpackConfig(serveTaskOptions, appConfig).buildConfig();

    const serverAddress = url.format({
      protocol: serveTaskOptions.ssl ? 'https' : 'http',
      hostname: serveTaskOptions.host,
      port: serveTaskOptions.port.toString()
    });
    let clientAddress = serverAddress;
    if (serveTaskOptions.liveReloadClient) {
      const clientUrl = url.parse(serveTaskOptions.liveReloadClient);
      // very basic sanity check
      if (!clientUrl.host) {
        return Promise.reject(new SilentError(`'live-reload-client' must be a full URL.`));
      }
      clientAddress = clientUrl.href;
    }

    if (serveTaskOptions.liveReload) {
      // This allows for live reload of page when changes are made to repo.
      // https://webpack.github.io/docs/webpack-dev-server.html#inline-mode
      let entryPoints = [
        `webpack-dev-server/client?${clientAddress}`
      ];
      if (serveTaskOptions.hmr) {
        const webpackHmrLink = 'https://webpack.github.io/docs/hot-module-replacement.html';
        ui.writeLine(oneLine`
          ${chalk.yellow('NOTICE')} Hot Module Replacement (HMR) is enabled for the dev server.
        `);
        ui.writeLine('  The project will still live reload when HMR is enabled,');
        ui.writeLine('  but to take advantage of HMR additional application code is required');
        ui.writeLine('  (not included in an Angular CLI project by default).');
        ui.writeLine(`  See ${chalk.blue(webpackHmrLink)}`);
        ui.writeLine('  for information on working with HMR for Webpack.');
        entryPoints.push('webpack/hot/dev-server');
        webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
        webpackConfig.plugins.push(new webpack.NamedModulesPlugin());
        if (serveTaskOptions.extractCss) {
          ui.writeLine(oneLine`
            ${chalk.yellow('NOTICE')} (HMR) does not allow for CSS hot reload when used
            together with '--extract-css'.
          `);
        }
      }
      if (!webpackConfig.entry.main) { webpackConfig.entry.main = []; }
      webpackConfig.entry.main.unshift(...entryPoints);
    } else if (serveTaskOptions.hmr) {
      ui.writeLine(chalk.yellow('Live reload is disabled. HMR option ignored.'));
    }

    if (!serveTaskOptions.watch) {
      // There's no option to turn off file watching in webpack-dev-server, but
      // we can override the file watcher instead.
      webpackConfig.plugins.unshift({
        apply: (compiler: any) => {
          compiler.plugin('after-environment', () => {
            compiler.watchFileSystem = { watch: () => {} };
          });
        }
      });
    }

    webpackCompiler = webpack(webpackConfig);

    if (rebuildDoneCb) {
      webpackCompiler.plugin('done', rebuildDoneCb);
    }

    const statsConfig = getWebpackStatsConfig(serveTaskOptions.verbose);

    let proxyConfig = {};
    if (serveTaskOptions.proxyConfig) {
      const proxyPath = path.resolve(this.project.root, serveTaskOptions.proxyConfig);
      if (fs.existsSync(proxyPath)) {
        proxyConfig = require(proxyPath);
      } else {
        const message = 'Proxy config file ' + proxyPath + ' does not exist.';
        return Promise.reject(new SilentError(message));
//.........這裏部分代碼省略.........
開發者ID:itslenny,項目名稱:angular-cli,代碼行數:101,代碼來源:serve.ts

示例8: afterEach

 afterEach(function () {
     rimraf.sync(dir.name);
 });
開發者ID:hmenager,項目名稱:composer,代碼行數:3,代碼來源:data-repository.spec.ts

示例9: afterAll

afterAll(() => {
  rimraf.sync(baseDir);
});
開發者ID:elastic,項目名稱:kibana,代碼行數:3,代碼來源:controller.test.ts

示例10:

 return source.forEach(p => rimraf.sync(p));
開發者ID:13812453806,項目名稱:angular2-seed,代碼行數:1,代碼來源:clear.files.ts


注:本文中的rimraf.sync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。