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


TypeScript promise.resolve函數代碼示例

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


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

示例1: fsCopy

 .then((files) => Promise.all(files.map((file) => {
   if (file === '.gitignore'){
     // don't overwrite the .gitignore file
     return Promise.resolve();
   }
   return fsCopy(path.join('dist', file), path.join('.', file))
 })));
開發者ID:DevVersion,項目名稱:angular-cli,代碼行數:7,代碼來源:github-pages-deploy.ts

示例2: updateBaseHref

 function updateBaseHref() {
   if (options.userPage) return Promise.resolve();
   let indexHtml = path.join(root, 'index.html');
   return fsReadFile(indexHtml, 'utf8')
     .then((data) => data.replace(/<base href="\/">/g, `<base href="/${projectName}/">`))
     .then((data) => fsWriteFile(indexHtml, data, 'utf8'));
 }
開發者ID:DevVersion,項目名稱:angular-cli,代碼行數:7,代碼來源:github-pages-deploy.ts

示例3: function

  cleanup: function() {
    var ui = this.ui;

    // if (this.webpack) {
      // this.webpack.cleanupAndExit();
      return Promise.resolve();
    // } else {
    //   return this.builder.cleanup().catch(function (err) {
    //     ui.writeLine(chalk.red('Cleanup error.'));
    //     ui.writeError(err);
    //   });
    // }
  },
開發者ID:TheLarkInn,項目名稱:angular-cli,代碼行數:13,代碼來源:builder.ts

示例4: build

 function build() {
   if (options.skipBuild) return Promise.resolve();
   return win.checkWindowsElevation(ui)
     .then(() => buildTask.run(buildOptions));
 }
開發者ID:DrMabuse23,項目名稱:angular-cli,代碼行數:5,代碼來源:github-pages-deploy.ts

示例5: function

  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 git@github.com:${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,代碼行數:69,代碼來源:create-github-repo.ts

示例6: function

    run: function (commandOptions, rawArgs): Promise<void> {
      this[stringUtils.camelize(this.name)](commandOptions, rawArgs);

      return Promise.resolve();
    },
開發者ID:2blessed2bstressedbythedevilsmess,項目名稱:angular-cli,代碼行數:5,代碼來源:easter-egg.ts

示例7: build

 function build() {
   if (options.skipBuild) return Promise.resolve();
   return buildTask.run(buildOptions);
 }
開發者ID:mmrath,項目名稱:angular-cli,代碼行數:4,代碼來源:github-pages-deploy.ts

示例8: function

    run: function (commandOptions, rawArgs): Promise<void> {
      var stringUtils = require('ember-cli/lib/utilities/string');
      this[stringUtils.camelize(this.name)](commandOptions, rawArgs);

      return Promise.resolve();
    },
開發者ID:Bigous,項目名稱:angular-cli,代碼行數:6,代碼來源:easter-egg.ts


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