本文整理汇总了TypeScript中ember-cli/lib/models/command.extend函数的典型用法代码示例。如果您正苦于以下问题:TypeScript extend函数的具体用法?TypeScript extend怎么用?TypeScript extend使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extend函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
module.exports = function(name) {
return Command.extend({
name: name,
works: 'insideProject',
run: function (commandOptions, rawArgs): Promise<void> {
var stringUtils = require('ember-cli/lib/utilities/string');
this[stringUtils.camelize(this.name)](commandOptions, rawArgs);
return Promise.resolve();
},
makeThisAwesome: function() {
const phrase = pickOne([
`You're on it, there's nothing for me to do!`,
`Let's take a look... nope, it's all good!`,
`You're doing fine.`,
`You're already doing great.`,
`Nothing to do; already awesome. Exiting.`,
`Error 418: As Awesome As Can Get.`
]);
console.log(chalk.green(phrase));
}
});
};
示例2: function
export default function(name: string) {
return Command.extend({
name: name,
works: 'insideProject',
run: function (commandOptions: any, rawArgs: string[]): Promise<void> {
(this as any)[stringUtils.camelize(this.name)](commandOptions, rawArgs);
return Promise.resolve();
},
makeThisAwesome: function() {
const phrase = pickOne([
`You're on it, there's nothing for me to do!`,
`Let's take a look... nope, it's all good!`,
`You're doing fine.`,
`You're already doing great.`,
`Nothing to do; already awesome. Exiting.`,
`Error 418: As Awesome As Can Get.`
]);
console.log(chalk.green(phrase));
}
});
};
示例3: SilentError
const NewCommand = Command.extend({
name: 'new',
description: `Creates a new directory and runs ${chalk.green('ng init')} in it.`,
works: 'outsideProject',
availableOptions: [
{ name: 'dry-run', type: Boolean, default: false, aliases: ['d'] },
{ name: 'verbose', type: Boolean, default: false, aliases: ['v'] },
{ name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] },
{ name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] },
{ name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] },
{ name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] },
{ name: 'directory', type: String, aliases: ['dir'] },
{ name: 'source-dir', type: String, default: 'src', aliases: ['sd'] },
{ name: 'style', type: String, default: 'css' },
{ name: 'prefix', type: String, default: 'app', aliases: ['p'] },
{ name: 'mobile', type: Boolean, default: false },
{ name: 'routing', type: Boolean, default: false },
{ name: 'inline-style', type: Boolean, default: false, aliases: ['is'] },
{ name: 'inline-template', type: Boolean, default: false, aliases: ['it'] }
],
run: function (commandOptions: any, rawArgs: string[]) {
const packageName = rawArgs.shift();
if (!packageName) {
return Promise.reject(new SilentError(
`The "ng ${this.name}" command requires a name argument to be specified. ` +
`For more details, use "ng help".`));
}
commandOptions.name = packageName;
if (commandOptions.dryRun) {
commandOptions.skipGit = true;
}
if (packageName === '.') {
return Promise.reject(new SilentError(
`Trying to generate an application structure in this directory? Use "ng init" ` +
`instead.`));
}
if (!validProjectName(packageName)) {
return Promise.reject(
new SilentError(`We currently do not support a name of "${packageName}".`));
}
if (commandOptions.mobile) {
return Promise.reject(new SilentError(
'The --mobile flag has been disabled temporarily while we await an update of ' +
'angular-universal for supporting NgModule. Sorry for the inconvenience.'
));
}
if (!commandOptions.directory) {
commandOptions.directory = packageName;
}
const createAndStepIntoDirectory =
new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics });
const initCommand = new InitCommand({
ui: this.ui,
analytics: this.analytics,
tasks: this.tasks,
project: Project.nullProject(this.ui, this.cli)
});
return createAndStepIntoDirectory
.run({
directoryName: commandOptions.directory,
dryRun: commandOptions.dryRun
})
.then(initCommand.run.bind(initCommand, commandOptions, rawArgs));
}
});
示例4: function
const VersionCommand = Command.extend({
name: 'version',
description: 'outputs angular-cli version',
aliases: ['v', '--version', '-v'],
works: 'everywhere',
availableOptions: [
{ name: 'verbose', type: Boolean, 'default': false }
],
run: function(options) {
var versions = process.versions;
var pkg = require(path.resolve(__dirname, '..', '..', '..', 'package.json'));
versions['os'] = process.platform + ' ' + process.arch;
var alwaysPrint = ['node', 'os'];
this.printVersion('angular-cli', pkg.version);
for (var module in versions) {
if (options.verbose || alwaysPrint.indexOf(module) > -1) {
this.printVersion(module, versions[module]);
}
}
},
printVersion: function(module, version) {
this.ui.writeLine(module + ': ' + version);
}
});
示例5: Promise
import * as chalk from 'chalk';
import * as Command from 'ember-cli/lib/models/command';
import {CliConfig} from '../models/config';
const GetCommand = Command.extend({
name: 'get',
description: 'Get a value from the configuration.',
works: 'everywhere',
availableOptions: [],
run: function (commandOptions, rawArgs): Promise<void> {
return new Promise(resolve => {
const value = new CliConfig().get(rawArgs[0]);
if (value === null) {
console.error(chalk.red('Value cannot be found.'));
} else if (typeof value == 'object') {
console.log(JSON.stringify(value));
} else {
console.log(value);
}
resolve();
});
}
});
module.exports = GetCommand;
示例6: function
import * as Command from 'ember-cli/lib/models/command';
import * as DocTask from '../tasks/doc';
const DocCommand = Command.extend({
name: 'doc',
description: 'Opens the official Angular documentation for a given keyword.',
works: 'everywhere',
anonymousOptions: [
'<keyword>'
],
run: function(commandOptions, rawArgs:Array<string>) {
var keyword = rawArgs[0];
var docTask = new DocTask({
ui: this.ui,
analytics: this.analytics,
project: this.project
});
return docTask.run(keyword);
}
});
module.exports = DocCommand;
示例7: WebpackBuildWatch
module.exports = Command.extend({
name: 'build',
description: 'Builds your app and places it into the output path (dist/ by default).',
aliases: ['b'],
availableOptions: [
{ name: 'environment', type: String, default: 'development', aliases: ['e', { 'dev': 'development' }, { 'prod': 'production' }] },
{ name: 'output-path', type: 'Path', default: 'dist/', aliases: ['o'] },
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },
{ name: 'watcher', type: String },
{ name: 'suppress-sizes', type: Boolean, default: false },
// Experimental webpack build for material team
{ name: 'm2', type: Boolean, default: false}
],
run: function (commandOptions: BuildOptions) {
var project = this.project;
var ui = this.ui;
var buildTask = commandOptions.watch ?
new WebpackBuildWatch({
cliProject: project,
ui: ui,
outputPath: commandOptions.outputPath,
environment: commandOptions.environment
}) :
new WebpackBuild({
cliProject: project,
ui: ui,
outputPath: commandOptions.outputPath,
environment: commandOptions.environment
});
console.log(buildTask);
return buildTask.run(commandOptions);
}
});
示例8: checkForPendingChanges
module.exports = Command.extend({
name: 'github-pages:deploy',
aliases: ['gh-pages:deploy'],
description: 'Build the test app for production, commit it into a git branch, setup GitHub repo and push to it',
works: 'insideProject',
availableOptions: [
{
name: 'message',
type: String,
default: 'new gh-pages version',
description: 'The commit message to include with the build, must be wrapped in quotes.'
}, {
name: 'environment',
type: String,
default: 'production',
description: 'The Angular environment to create a build for'
}, {
name: 'branch',
type: String,
default: 'gh-pages',
description: 'The git branch to push your pages to'
}, {
name: 'skip-build',
type: Boolean,
default: false,
description: 'Skip building the project before deploying'
}, {
name: 'gh-token',
type: String,
default: '',
description: 'Github token'
}, {
name: 'gh-username',
type: String,
default: '',
description: 'Github username'
}],
run: function(options, rawArgs) {
var ui = this.ui;
var root = this.project.root;
var execOptions = {
cwd: root
};
var projectName = this.project.pkg.name;
let initialBranch;
// declared here so that tests can stub exec
const execPromise = Promise.denodeify(exec);
var buildTask = new BuildTask({
ui: this.ui,
analytics: this.analytics,
project: this.project
});
var buildOptions = {
environment: options.environment,
outputPath: 'dist/'
};
var createGithubRepoTask = new CreateGithubRepo({
ui: this.ui,
analytics: this.analytics,
project: this.project
});
var createGithubRepoOptions = {
projectName,
ghUsername: options.ghUsername,
ghToken: options.ghToken
};
return checkForPendingChanges()
.then(build)
.then(saveStartingBranchName)
.then(createGitHubRepoIfNeeded)
.then(checkoutGhPages)
.then(copyFiles)
.then(updateBaseHref)
.then(addAndCommit)
.then(returnStartingBranch)
.then(pushToGitRepo)
.then(printProjectUrl);
function checkForPendingChanges() {
return execPromise('git status --porcelain')
.then(stdout => {
if (/\w+/m.test(stdout)) {
let msg = 'Uncommitted file changes found! Please commit all changes before deploying.';
return Promise.reject(new SilentError(msg));
}
});
}
function build() {
if (options.skipBuild) return Promise.resolve();
return win.checkWindowsElevation(ui)
//.........这里部分代码省略.........
示例9: require
const Command = require('ember-cli/lib/models/command');
import {E2eTask} from '../tasks/e2e';
import {CliConfig} from '../models/config';
const E2eCommand = Command.extend({
name: 'e2e',
description: 'Run e2e tests in existing project',
works: 'insideProject',
run: function () {
this.project.ngConfig = this.project.ngConfig || CliConfig.fromProject();
const e2eTask = new E2eTask({
ui: this.ui,
analytics: this.analytics,
project: this.project
});
return e2eTask.run();
}
});
export default E2eCommand;
示例10: Promise
import * as Command from 'ember-cli/lib/models/command';
import {CliConfig} from '../models/config';
const SetCommand = Command.extend({
name: 'set',
description: 'Set a value in the configuration.',
works: 'outsideProject',
availableOptions: [
{ name: 'global', type: Boolean, default: false, aliases: ['g'] },
],
run: function (commandOptions, rawArgs): Promise<void> {
return new Promise(resolve => {
const config = new CliConfig();
config.set(rawArgs[0], rawArgs[1], commandOptions.force);
config.save();
resolve();
});
}
});
module.exports = SetCommand;
module.exports.overrideCore = true;