1
1
2
- const { addDepsAtWorkspace, logSuccess, logError, logInfo } = require ( './scripts.module' )
3
- const { program } = require ( 'commander' ) ;
2
+ const { addDepsAtWorkspace, logSuccess, logError } = require ( './scripts.module' )
4
3
5
-
6
- program
7
- . command ( 'add' )
8
- . description ( 'Adds dependencies at given workspace and updates package.json' )
9
- . requiredOption ( '-n, --workspace-name <name>' , 'Name of the workspace where to add dependencies' )
10
- . option ( '-d, --workspace-directory <directory>' , 'Directory where to look for the workspace. Defaults to "microservices"' , 'microservices' )
11
- . argument ( '<packages...>' , 'Space-separated list of packages to add' )
12
- . action ( async ( packages , options ) => {
13
- try {
14
- const message = await addDepsAtWorkspace ( {
15
- workspace_name : options . workspaceName ,
16
- workspace_directory : options . workspaceDirectory ,
17
- packages : packages . join ( ' ' )
18
- } ) ;
19
- logSuccess ( { message } )
20
- } catch ( error ) {
21
- const CODE = error . split ( ':' ) [ 1 ]
22
- if ( ! [ ' EEXIST' , ' ENOENT' , ' EINVAL' , ' ENOTDIR' ] . includes ( CODE ) ) logError ( { error } )
23
- }
24
- } ) ;
25
- program . parse ( process . argv ) ;
26
- module . exports = program
4
+ module . exports = async ( { packages, options } ) => {
5
+ try {
6
+ const message = await addDepsAtWorkspace ( {
7
+ workspace_name : options . workspaceName ,
8
+ workspace_directory : options . workspaceDirectory ,
9
+ packages : packages . join ( ' ' )
10
+ } ) ;
11
+ logSuccess ( { message } )
12
+ } catch ( error ) {
13
+ const CODE = error . split ( ':' ) [ 1 ]
14
+ if ( ! [ ' EEXIST' , ' ENOENT' , ' EINVAL' , ' ENOTDIR' ] . includes ( CODE ) ) logError ( { error } )
15
+ }
16
+ }
0 commit comments