Skip to content

Commit

Permalink
Copy plugin test and example template files in generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ianjsikes committed Sep 5, 2017
1 parent 7d6fd90 commit 4aa82f2
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion lib/generate-plugin/plugin-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class PluginGenerator extends Generator {
}

writing() {
/**
* Plugin source
*/

this.fs.copyTpl(
path.join(__dirname, 'templates', 'src', '_index.js.tpl'),
this.destinationPath('src/index.js'),
Expand All @@ -52,10 +56,49 @@ class PluginGenerator extends Generator {
path.join(__dirname, 'templates', 'src', 'cjs.js.tpl'),
this.destinationPath('src/cjs.js')
);

/**
* Tests
*/

this.fs.copy(
path.join(__dirname, 'templates', 'test', 'test-utils.js.tpl'),
this.destinationPath('test/test-utils.js')
);

this.fs.copy(
path.join(__dirname, 'templates', 'test', 'functional.test.js.tpl'),
this.destinationPath('test/functional.test.js')
);

/**
* Examples
*/

this.fs.copyTpl(
path.join(__dirname, 'templates', 'examples', 'simple', 'webpack.config.js.tpl'),
this.destinationPath('examples/simple/webpack.config.js'),
{ name: _.upperFirst(_.camelCase(this.props.name)) }
);

this.fs.copy(
path.join(__dirname, 'templates', 'examples', 'simple', 'src','index.js.tpl'),
this.destinationPath('examples/simple/src/index.js')
);

this.fs.copy(
path.join(__dirname, 'templates', 'examples', 'simple', 'src','lazy-module.js.tpl'),
this.destinationPath('examples/simple/src/lazy-module.js')
);

this.fs.copy(
path.join(__dirname, 'templates', 'examples', 'simple', 'src','static-esm-module.js.tpl'),
this.destinationPath('examples/simple/src/static-esm-module.js')
);
}

install() {
this.npmInstall(['webpack-defaults'], { 'save-dev': true }).then(() => {
this.npmInstall(['webpack-defaults', 'bluebird'], { 'save-dev': true }).then(() => {
this.spawnCommand('npm', ['run', 'webpack-defaults']);
});
}
Expand Down

0 comments on commit 4aa82f2

Please sign in to comment.