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

TypeScript task.extend函数代码示例

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

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



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

示例1: Promise

module.exports = Task.extend({
  // Options: String outputPath
  run: function(runTaskOptions: ServeTaskOptions) {

    var project = this.cliProject;

    rimraf.sync(path.resolve(project.root, runTaskOptions.outputPath));
    var config = new NgCliWebpackConfig(project, runTaskOptions.environment).config;
    const webpackCompiler = webpack(config);

    const ProgressPlugin  = require('webpack/lib/ProgressPlugin');

    webpackCompiler.apply(new ProgressPlugin({
      profile: true
    }));

    return new Promise((resolve, reject) => {
      webpackCompiler.run((err, stats) => {
        // Don't keep cache
        // TODO: Make conditional if using --watch
        webpackCompiler.purgeInputFileSystem();

        if(err) {
          lastHash = null;
          console.error(err.stack || err);
          if(err.details) console.error(err.details);
            reject(err.details);
        }

        if(stats.hash !== lastHash) {
          lastHash = stats.hash;
          process.stdout.write(stats.toString(webpackOutputOptions) + "\n");
        }
        resolve();
      });
    });
  }
});
开发者ID:TheLarkInn,项目名称:angular-cli,代码行数:38,代码来源:build-webpack.ts


示例2: requireDependency

import * as path from 'path';

// require dependencies within the target project
function requireDependency(root: string, moduleName: string) {
  const packageJson = require(path.join(root, 'node_modules', moduleName, 'package.json'));
  const main = path.normalize(packageJson.main);
  return require(path.join(root, 'node_modules', moduleName, main));
}

export default Task.extend({
  run: function (options: any) {
    const projectRoot = this.project.root;
    return new Promise((resolve) => {
      const karma = requireDependency(projectRoot, 'karma');
      const karmaConfig = path.join(projectRoot, this.project.ngConfig.config.test.karma.config);

      // Convert browsers from a string to an array
      if (options.browsers) {
        options.browsers = options.browsers.split(',');
      }

      // Assign additional karmaConfig options to the local ngapp config
      options.configFile = karmaConfig;

      // :shipit:
      const karmaServer = new karma.Server(options, resolve);
      karmaServer.start();
    });
  }
});
开发者ID:JasonGoemaat,项目名称:angular-cli,代码行数:30,代码来源:test.ts


示例3: Promise

module.exports = Task.extend({
  run: function(commandOptions) {
    var ui = this.ui;
    let promise;

    // declared here so that tests can stub exec
    const execPromise = Promise.denodeify(exec);

    if (/.+/.test(commandOptions.ghToken) && /\w+/.test(commandOptions.ghUsername)) {
      promise = Promise.resolve({
        ghToken: commandOptions.ghToken,
        ghUsername: commandOptions.ghUsername
      });
    } else {
      ui.writeLine("\nIn order to deploy this project via GitHub Pages, we must first create a repository for it.");
      ui.writeLine("It's safer to use a token than to use a password, so you will need to create one.\n");
      ui.writeLine("Go to the following page and click 'Generate new token'.");
      ui.writeLine("https://github.com/settings/tokens\n");
      ui.writeLine("Choose 'public_repo' as scope and then click 'Generate token'.\n");
      promise = ui.prompt([
        {
          name: 'ghToken',
          type: 'input',
          message: 'Please enter GitHub token you just created (used only once to create the repo):',
          validate: function(token) {
            return /.+/.test(token);
          }
        }, {
          name: 'ghUsername',
          type: 'input',
          message: 'and your GitHub user name:',
          validate: function(userName) {
            return /\w+/.test(userName);
          }
        }]);
    }

    return promise
      .then((answers) => {
      return new Promise(function(resolve, reject) {
        var postData = JSON.stringify({
          'name': commandOptions.projectName
        });

        var req = https.request({
          hostname: 'api.github.com',
          port: 443,
          path: '/user/repos',
          method: 'POST',
          headers: {
            'Authorization': `token ${answers.ghToken}`,
            'Content-Type': 'application/json',
            'Content-Length': postData.length,
            'User-Agent': 'angular-cli-github-pages'
          }
        });

        req.on('response', function(response) {
          if (response.statusCode === 201) {
            resolve(execPromise(`git remote add origin [email protected]:${answers.ghUsername}/${commandOptions.projectName}.git`))
          } else {
            reject(new SilentError(`Failed to create GitHub repo. Error: ${response.statusCode} ${response.statusMessage}`));
          }
        });

        req.write(postData);
        req.end();
      });
    });
  }
});
开发者ID:2blessed2bstressedbythedevilsmess,项目名称:angular-cli,代码行数:71,代码来源:create-github-repo.ts


示例4: require

const Task = require('ember-cli/lib/models/task');
import * as chalk from 'chalk';
import {exec} from 'child_process';


export const E2eTask = Task.extend({
  run: function () {
    const ui = this.ui;
    let exitCode = 0;

    return new Promise((resolve) => {
      exec(`npm run e2e -- ${this.project.ngConfig.config.e2e.protractor.config}`,
        (err: NodeJS.ErrnoException, stdout: string, stderr: string) => {
          ui.writeLine(stdout);
          if (err) {
            ui.writeLine(stderr);
            ui.writeLine(chalk.red('Some end-to-end tests failed, see above.'));
            exitCode = 1;
          } else {
            ui.writeLine(chalk.green('All end-to-end tests pass.'));
          }
          resolve(exitCode);
        });
    });
  }
});
开发者ID:JasonGoemaat,项目名称:angular-cli,代码行数:26,代码来源:e2e.ts


示例5: opn

import * as Task from 'ember-cli/lib/models/task';
import * as opn from 'opn';

const DocTask = Task.extend({
  run: function(keyword: string) {
    var searchUrl = `https://angular.io/docs/ts/latest/api/#!?apiFilter=${keyword}`; 
    return opn(searchUrl, { wait: false });
  }
});

module.exports = DocTask;
开发者ID:2blessed2bstressedbythedevilsmess,项目名称:angular-cli,代码行数:11,代码来源:doc.ts


示例6: Promise

module.exports = Task.extend({
  run: function(commandOptions: ServeTaskOptions) {

    let lastHash = null;
    let webpackCompiler: any;

    var config: NgCliWebpackConfig = new NgCliWebpackConfig(this.project, commandOptions.target, commandOptions.environment).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
    config.entry.main.unshift(`webpack-dev-server/client?http://${commandOptions.host}:${commandOptions.port}/`);
    webpackCompiler = webpack(config);

    webpackCompiler.apply(new ProgressPlugin({
      profile: true,
      colors: true
    }));

    const webpackDevServerConfiguration: IWebpackDevServerConfigurationOptions = {
      contentBase: path.resolve(this.project.root, `./${CliConfig.fromProject().defaults.sourceDir}`),
      historyApiFallback: true,
      stats: webpackDevServerOutputOptions,
      inline: true
    };

    const serveMessage:string = chalk.green(`\n*\n*\n NG Live Development Server is running on http://${commandOptions.host}:${commandOptions.port}.\n*\n*`);
    const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration);

    return new Promise((resolve, reject) => {
      server.listen(commandOptions.port, `${commandOptions.host}`, function(err, stats) {
        if(err) {
          lastHash = null;
          console.error(err.stack || err);
          if(err.details) console.error(err.details);
            reject(err.details);
        }

        if(stats && stats.hash && stats.hash !== lastHash) {
          lastHash = stats.hash;
          process.stdout.write(stats.toString(webpackOutputOptions) + '\n' + serveMessage + '\n');
        }

        process.stdout.write(serveMessage);
      });
    })
  }
});
开发者ID:Alber70g,项目名称:angular-cli,代码行数:46,代码来源:serve-webpack.ts


示例7: Promise

export default Task.extend({
  run: function(runTaskOptions: BuildOptions) {

    const project = this.cliProject;

    const outputDir = runTaskOptions.outputPath || CliConfig.fromProject().config.apps[0].outDir;
    rimraf.sync(path.resolve(project.root, outputDir));

    const config = new NgCliWebpackConfig(
      project,
      runTaskOptions.target,
      runTaskOptions.environment,
      outputDir,
      runTaskOptions.baseHref,
      runTaskOptions.aot
    ).config;
    const webpackCompiler: any = webpack(config);

    webpackCompiler.apply(new ProgressPlugin({
      profile: true
    }));

    return new Promise((resolve, reject) => {
      webpackCompiler.watch({}, (err: any, stats: any) => {
        if (err) {
          lastHash = null;
          console.error(err.stack || err);
          if (err.details) { console.error(err.details); }
            reject(err.details);
        }

        if (stats.hash !== lastHash) {
          lastHash = stats.hash;
          process.stdout.write(stats.toString(webpackOutputOptions) + '\n');
        }
      });
    });
  }
});
开发者ID:dlizarra,项目名称:angular-cli,代码行数:39,代码来源:build-webpack-watch.ts


示例8: Promise

export default Task.extend({
  run: function(commandOptions: ServeTaskOptions) {
    const ui = this.ui;

    let webpackCompiler: any;

    let config = new NgCliWebpackConfig(
      this.project, commandOptions.target,
      commandOptions.environment
    ).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
    config.entry.main.unshift(
      `webpack-dev-server/client?http://${commandOptions.host}:${commandOptions.port}/`
    );
    webpackCompiler = webpack(config);

    webpackCompiler.apply(new ProgressPlugin({
      profile: true,
      colors: true
    }));

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

    const webpackDevServerConfiguration: IWebpackDevServerConfigurationOptions = {
      contentBase: path.resolve(
        this.project.root,
        `./${CliConfig.fromProject().config.apps[0].root}`
      ),
      historyApiFallback: true,
      stats: webpackDevServerOutputOptions,
      inline: true,
      proxy: proxyConfig
    };

    ui.writeLine(chalk.green(oneLine`
      **
      NG Live Development Server is running on
      http://${commandOptions.host}:${commandOptions.port}.
      **
    `));

    const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration);
    return new Promise((resolve, reject) => {
      server.listen(commandOptions.port, `${commandOptions.host}`, function(err: any, stats: any) {
        if (err) {
          console.error(err.stack || err);
          if (err.details) { console.error(err.details); }
          reject(err.details);
        }
      });
    });
  }
});
开发者ID:StudioProcess,项目名称:angular-cli,代码行数:64,代码来源:serve-webpack.ts


示例9: Promise

import * as Promise from 'ember-cli/lib/ext/promise';
import * as Task from 'ember-cli/lib/models/task';
import * as chalk from 'chalk';
import {exec} from 'child_process';

module.exports = Task.extend({
  run: function() {
    var ui = this.ui;

    return new Promise(function(resolve, reject) {
      exec('npm link angular-cli', (err) => {
        if (err) {
          ui.writeLine(chalk.red('Couldn\'t do \'npm link angular-cli\'.'));
          reject();
        } else {
          ui.writeLine(chalk.green('Successfully linked to angular-cli.'));
          resolve();
        }
      });
    });
  }
});
开发者ID:Alber70g,项目名称:angular-cli,代码行数:22,代码来源:link-cli.ts


示例10: Promise

module.exports = Task.extend({
  run: function(commandOptions: ServeTaskOptions) {

    let webpackCompiler: any;

    var config: NgCliWebpackConfig = new NgCliWebpackConfig(this.project, commandOptions.environment).config;
    webpackCompiler = webpack(config);


    webpackCompiler.apply(new ProgressPlugin({
      profile: true,
      colors: true
    }));

    const webpackDevServerConfiguration: IWebpackDevServerConfigurationOptions = {
      contentBase: path.resolve(this.project.root, './src'),
      historyApiFallback: true,
      stats: webpackDevServerOutputOptions,
      inline: true
    };

    const serveMessage:string = chalk.green(`\n*\n*\n NG Live Development Server is running on http://localhost:${commandOptions.port}.\n*\n*`);
    const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration);

    return new Promise((resolve, reject) => {
      server.listen(commandOptions.port, "localhost", function(err, stats) {
        if(err) {
          lastHash = null;
          console.error(err.stack || err);
          if(err.details) console.error(err.details);
            reject(err.details);
        }

        if(stats && stats.hash && stats.hash !== lastHash) {
          lastHash = stats.hash;
          process.stdout.write(stats.toString(webpackOutputOptions) + "\n" + serveMessage + "\n");
        }

        process.stdout.write(serveMessage);
      });
    })
  }
});
开发者ID:TheLarkInn,项目名称:angular-cli,代码行数:43,代码来源:serve-webpack.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript build.run函数代码示例发布时间:2022-05-25
下一篇:
TypeScript project.nullProject函数代码示例发布时间: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