本文整理匯總了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))
})));
示例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'));
}
示例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);
// });
// }
},
示例4: build
function build() {
if (options.skipBuild) return Promise.resolve();
return win.checkWindowsElevation(ui)
.then(() => buildTask.run(buildOptions));
}
示例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();
});
});
}
示例6: function
run: function (commandOptions, rawArgs): Promise<void> {
this[stringUtils.camelize(this.name)](commandOptions, rawArgs);
return Promise.resolve();
},
示例7: build
function build() {
if (options.skipBuild) return Promise.resolve();
return buildTask.run(buildOptions);
}
示例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();
},