本文整理汇总了TypeScript中yeoman-test.registerDependencies函数的典型用法代码示例。如果您正苦于以下问题:TypeScript registerDependencies函数的具体用法?TypeScript registerDependencies怎么用?TypeScript registerDependencies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了registerDependencies函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test
test(testName, async () => {
const yeomanEnv = new YeomanEnvironment();
const promptStub =
sinon.stub(inquirer, 'prompt').returns(Promise.resolve({
foo: 'TEST',
}));
helpers.registerDependencies(yeomanEnv, [[
// tslint:disable-next-line: no-any
function() {} as any,
'polymer-init-custom-template:app',
]]);
try {
await polymerInit.promptGeneratorSelection({env: yeomanEnv});
} catch (error) {
assert.equal(error.message, 'Template TEST not found');
}
assert.isTrue(promptStub.calledOnce);
const choices =
(promptStub.firstCall.args[0] as inquirer.Question[])[0].choices as
inquirer.objects.ChoiceOption[];
const customGeneratorChoice = choices[choices.length - 1];
assert.equal(stripAnsi(customGeneratorChoice.name!), 'custom-template');
assert.equal(
customGeneratorChoice.value, 'polymer-init-custom-template:app');
// tslint:disable-next-line: no-any
assert.equal((customGeneratorChoice as any).short, 'custom-template');
});
开发者ID:Polymer,项目名称:tools,代码行数:27,代码来源:init_test.ts
示例2: test
test(testName, async () => {
const yeomanEnv = new YeomanEnvironment();
const promptStub =
sandbox.stub(inquirer, 'prompt').returns(Promise.resolve({
foo: 'TEST',
}));
helpers.registerDependencies(yeomanEnv, [[
helpers.createDummyGenerator(),
'polymer-init-custom-template:app',
]]);
try {
await polymerInit.promptGeneratorSelection({env: yeomanEnv});
} catch (error) {
assert.equal(error.message, 'Template TEST not found');
}
assert.isTrue(promptStub.calledOnce);
const choices = promptStub.firstCall.args[0][0].choices;
const customGeneratorChoice = choices[choices.length - 1];
assert.equal(stripAnsi(customGeneratorChoice.name), 'custom-template');
assert.equal(
customGeneratorChoice.value, 'polymer-init-custom-template:app');
assert.equal(customGeneratorChoice.short, 'custom-template');
});
开发者ID:abdonrd,项目名称:polymer-cli,代码行数:23,代码来源:init_test.ts
示例3:
helpers.mockLocalConfig(generator, {foo: 'bar'});
// helpers.createDummyGenerator()
const dummyGenerator = helpers.createDummyGenerator();
// helpers.createGenerator()
const angularGenerator = helpers.createGenerator('angular:app', [
'../../app',
'../../common',
'../../controller',
'../../main',
[helpers.createDummyGenerator(), 'testacular:app']
]);
// helpers.registerDependencies()
helpers.registerDependencies(env, ['dependency']);
// helpers.run()
helpers.run(path.join(__dirname, '../app'))
.withOptions({foo: 'bar'})
.withArguments(['name-x'])
.withPrompts({coffee: false});
helpers.run(path.join(__dirname, '../app'))
.inTmpDir(dir => { /* ... */ })
.withPrompts({coffee: false})
.then(() => { /* ... */ });
helpers.run(path.join(__dirname, '../app')).withGenerators([
[helpers.createDummyGenerator(), 'karma:app'],
]);
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:yeoman-test-tests.ts
示例4: function
RunContext.prototype._run = function(): void {
if (!this.inDirSet && this.settings.tmpdir) {
this.inTmpDir();
}
if (this._asyncHolds !== 0 || this.ran) {
return;
}
this.ran = true;
let namespace;
this.env = yeoman.createEnv([], {}, new TestAdapter());
helpers.registerDependencies(this.env, this.dependencies);
if (_.isString(this.Generator)) {
try {
const lstats = fs.lstatSync(this.Generator);
if (lstats.isDirectory()) {
const ext = path.extname(this.Generator);
namespace = this.env.namespace(this.Generator) + ext;
} else {
namespace = this.env.namespace(this.Generator);
}
} catch (e) {
namespace = this.env.namespace(this.Generator);
}
this.env.register(this.Generator);
} else {
namespace = this.settings.namespace;
this.env.registerStub(this.Generator, namespace, this.settings.resolved);
}
this.generator = this.env.create(namespace, {
arguments: this.args,
options: this.options
});
helpers.mockPrompt(this.generator, this.answers);
if (this.localConfig) {
// only mock local config when withLocalConfig was called
helpers.mockLocalConfig(this.generator, this.localConfig);
}
this.generator.on(
"error",
(err: Error): void => {
if (!this.emit("error", err)) {
throw err;
}
}
);
this.generator.once(
"end",
(): void => {
helpers.restorePrompt(this.generator);
this.emit("end");
this.completed = true;
}
);
this.emit("ready", this.generator);
this.generator.run();
};
开发者ID:jlenoble,项目名称:generator-wupjs,代码行数:67,代码来源:run-context.ts
注:本文中的yeoman-test.registerDependencies函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论