Skip to content

Commit

Permalink
feat: added hook for peerDeps installed check
Browse files Browse the repository at this point in the history
  • Loading branch information
kotarella1110 committed Oct 3, 2019
1 parent 2b86b41 commit d30db39
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugin.xml
Expand Up @@ -5,6 +5,7 @@
<author>Kotaro Sugawara</author>
<keywords>cordova,webpack</keywords>
<license>Apache 2.0</license>
<hook src="scripts/peerDepsInstalledCheck.js" type="before_plugin_install"/>
<hook src="scripts/webpackCompile.js" type="before_prepare"/>
<hook src="scripts/webpackServe.js" type="after_prepare"/>
</plugin>
33 changes: 33 additions & 0 deletions src/peerDepsInstalledCheck.ts
@@ -0,0 +1,33 @@
import 'source-map-support/register';

module.exports = async () => {
try {
require.resolve('webpack');
} catch (err) {
console.error("Please install 'webpack' to use the plugin");
console.error('-> When using npm: npm i -D webpack');
console.error('-> When using yarn: yarn add -D webpack');

throw err;
}

try {
require.resolve('webpack-cli');
} catch (err) {
console.error("Please install 'webpack-cli' to use the plugin");
console.error('-> When using npm: npm i -D webpack-cli');
console.error('-> When using yarn: yarn add -D webpack-cli');

throw err;
}

try {
require.resolve('webpack-dev-server');
} catch (err) {
console.error("Please install 'webpack-dev-server' to use the plugin");
console.error('-> When using npm: npm i -D webpack-dev-server');
console.error('-> When using yarn: yarn add -D webpack-dev-server');

throw err;
}
};

0 comments on commit d30db39

Please sign in to comment.