Skip to content

Commit

Permalink
cli: fix various of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
evenstensberg committed Nov 4, 2018
1 parent 4b9df8d commit 1e7ad51
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/generators/add-generator.ts
Expand Up @@ -3,7 +3,7 @@ import Generator = require("yeoman-generator");
import * as glob from "glob-all";
import * as autoComplete from "inquirer-autocomplete-prompt";
import * as path from "path";
import webpackDevServerSchema from "webpack-dev-server/lib/optionsSchema.json";
import webpackDevServerSchema from "webpack-dev-server/lib/options.json";

import npmExists from "@webpack-cli/utils/npm-exists";
import { getPackageManager } from "@webpack-cli/utils/package-manager";
Expand Down
13 changes: 11 additions & 2 deletions packages/remove/index.ts
Expand Up @@ -4,11 +4,20 @@ import modifyConfigHelper from "@webpack-cli/utils/modify-config-helper";
/**
* Is called and returns a scaffolding instance, removing properties
*
* @param {String[]} args - array of arguments such as
* @returns {Function} modifyConfigHelper - A helper function that uses the action
* we're given on a generator
*
*/

export default function() {
return modifyConfigHelper("remove", defaultGenerator);
export default function remove(...args: string[]): Function {
const DEFAULT_WEBPACK_CONFIG_FILENAME: string = "webpack.config.js";

const filePaths: string[] = args.slice(3);
let configFile: string = DEFAULT_WEBPACK_CONFIG_FILENAME;
if (filePaths.length) {
configFile = filePaths[0];
}

return modifyConfigHelper("remove", defaultGenerator, configFile);
}
13 changes: 11 additions & 2 deletions packages/update/index.ts
Expand Up @@ -4,11 +4,20 @@ import modifyConfigHelper from "@webpack-cli/utils/modify-config-helper";
/**
* Is called and returns a scaffolding instance, updating properties
*
* @param {String[]} args - array of arguments such as
* @returns {Function} modifyConfigHelper - A helper function that uses the action
* we're given on a generator
*
*/

export default function() {
return modifyConfigHelper("update", defaultGenerator);
export default function update(...args: string[]): Function {
const DEFAULT_WEBPACK_CONFIG_FILENAME: string = "webpack.config.js";

const filePaths: string[] = args.slice(3);
let configFile: string = DEFAULT_WEBPACK_CONFIG_FILENAME;
if (filePaths.length) {
configFile = filePaths[0];
}

return modifyConfigHelper("update", defaultGenerator, configFile);
}
5 changes: 4 additions & 1 deletion packages/utils/modify-config-helper.ts
Expand Up @@ -88,7 +88,7 @@ export default function modifyHelperUtil(
}
env.registerStub(generator, generatorName);

env.run(generatorName).on("end", (_: void) => {
env.run(generatorName).then((_: void) => {
let configModule: object;
try {
const confPath: string = path.resolve(process.cwd(), ".yo-rc.json");
Expand Down Expand Up @@ -122,5 +122,8 @@ export default function modifyHelperUtil(
configModule,
);
return runTransform(transformConfig, action);
}).catch(err => {
console.error(chalk.red('\nUnexpected Error, please file an issue to https://github.com/webpack/webpack-cli\n'));
console.error(err);
});
}

0 comments on commit 1e7ad51

Please sign in to comment.