@@ -6,22 +6,6 @@ import * as path from "path";
6
6
7
7
import { processPromise } from "@webpack-cli/utils/resolve-packages" ;
8
8
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
-
25
9
interface Commands {
26
10
dependency : string [ ] ;
27
11
devDependency : string [ ] ;
@@ -45,16 +29,24 @@ const pmConfig: PackageManagerConfig = {
45
29
}
46
30
} ;
47
31
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
+
48
49
const 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
- */
58
50
const [ installCmd , ...flags ] = pmConfig [ pm ] [ cmd ] ;
59
51
const options : string [ ] = [ installCmd , "webpack-dev-server" , ...flags ] ;
60
52
return spawn . sync ( pm , options , { stdio : "inherit" } ) ;
0 commit comments