Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as path from 'path';
import * as helpers from 'yeoman-test';
import Generator = require('yeoman-generator');
declare const env: any;
declare const generator: Generator;
declare function before(done: (...args: any[]) => void): void;
// helpers.setUpTestDirectory()
before(helpers.setUpTestDirectory('dir'));
// helpers.gruntfile()
before(done => helpers.gruntfile({foo: 'bar'}, done));
// helpers.testDirectory()
helpers.testDirectory(path.join(__dirname, './temp'), () => {
fs.writeFileSync('testfile', 'Roses are red.');
});
// helpers.mockPrompt()
helpers.mockPrompt(generator, {foo: 'bar'});
// helpers.restorePrompt()
helpers.restorePrompt(generator);
// helpers.mockLocalConfig()
helpers.mockLocalConfig(generator, {foo: 'bar'});
// helpers.createDummyGenerator()
const dummyGenerator = helpers.createDummyGenerator();
// helpers.createGenerator()
test.beforeEach(async () => {
await pify(helpers.testDirectory)(path.join(__dirname, 'temp'));
generator = helpers.createGenerator('pwa', ['../../generators/app/'], null, {skipInstall: true});
});
beforeEach(function (done) {
this.timeout(10000);
var deps = [
'../../generators/app',
'../../generators/endpoint',
[
helpers.createDummyGenerator(),
'ng-component:app'
]
];
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
if (err) {
return done(err);
}
gen = helpers.createGenerator('angular-fullstack:app', deps, [], {
skipInstall: true
});
gen.conflicter.force = true;
done();
}.bind(this));
});
beforeEach(function(done) {
helpers.testDirectory(testDirectory, function(err) {
if (err) {
return done(err);
}
this.rule = helpers.createGenerator("eslint:rule", [
"../rule"
]);
return done();
}.bind(this));
});
beforeEach(function(done) {
helpers.testDirectory(testDirectory, function(err) {
if (err) {
return done(err);
}
this.rule = helpers.createGenerator("eslint:plugin", [
"../plugin"
]);
return done();
}.bind(this));
});
beforeEach(function (done) {
helpers.testDirectory(tempPath, function (err) {
if (err) {
return done(err);
}
this.app = helpers.createGenerator('nodejs:app', [
'../app'
], [], { 'skip-install': true });
done();
}.bind(this));
});
before(function(done) {
this.spy = sandbox.spy();
this.dummyGenerator = generators.Base.extend({
exec: this.spy
});
helpers.testDirectory(path.join(__dirname, "../../temp"), done);
});
module.exports = function run(config, done) {
var dir = path.join(__dirname, '..', '..', 'tmp');
helpers.testDirectory(dir, function (err) {
if (err) {
return done(err);
}
var app = helpers.createGenerator(config.type, config.dependencies, config.args, config.options);
helpers.mockPrompt(app, config.prompt);
app.run(function () {
done(null, app);
});
});
};
exports.run = function run(prompts, callback) {
const fountain = helpers.createGenerator('fountain-webapp:app', [generatorPath], null);
helpers.mockPrompt(fountain, prompts);
helpers.testDirectory(workPath, () => {
fountain.run(() => {
const test = spawn('gulp', ['test'], {stdio: 'inherit'});
test.on('exit', callback);
});
});
};
beforeEach(function (done) {
this.timeout(10000);
var deps = [
'../../app',
[
helpers.createDummyGenerator(),
'ng-component:app'
]
];
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
if (err) {
return done(err);
}
gen = helpers.createGenerator('angular-material-fullstack:app', deps);
gen.options['skip-install'] = true;
done();
}.bind(this));
});