@@ -6,22 +6,6 @@ import * as path from "path";
66
77import { processPromise } from "@webpack-cli/utils/resolve-packages" ;
88
9- /**
10- *
11- * Installs WDS using NPM with --save --dev etc
12- *
13- * @param {Object } cmd - arg to spawn with
14- * @returns {Void }
15- */
16-
17- /**
18- *
19- * Installs WDS using Yarn with add etc
20- *
21- * @param {Object } cmd - arg to spawn with
22- * @returns {Void }
23- */
24-
259interface Commands {
2610 dependency : string [ ] ;
2711 devDependency : string [ ] ;
@@ -45,16 +29,24 @@ const pmConfig: PackageManagerConfig = {
4529 }
4630} ;
4731
32+ /**
33+ *
34+ * Installs WDS using the respective package manager with add etc
35+ *
36+ * @param {String } pm - package manager to be used
37+ * @param {String } cmd - arg to spawn with
38+ * @returns {Function } spawn - installs WDS
39+ *
40+ * The dependency installation commands for the
41+ * respective package manager is available as
42+ * nested objects within pmConfig
43+ *
44+ * We gonna extract the root installation command
45+ * and rest of the flags from pmConfig object
46+ * by means of array destructuring
47+ */
48+
4849const spawnWithArg = ( pm : string , cmd : string ) : SpawnSyncReturns < Buffer > => {
49- /*
50- * The dependency installation commands for the
51- * respective package manager is available as
52- * nested objects within pmConfig
53- *
54- * We gonna extract the root installation command
55- * and rest of the flags from pmConfig object
56- * by means of array destructuring
57- */
5850 const [ installCmd , ...flags ] = pmConfig [ pm ] [ cmd ] ;
5951 const options : string [ ] = [ installCmd , "webpack-dev-server" , ...flags ] ;
6052 return spawn . sync ( pm , options , { stdio : "inherit" } ) ;
0 commit comments