File tree Expand file tree Collapse file tree 3 files changed +22
-9
lines changed Expand file tree Collapse file tree 3 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -53,13 +53,13 @@ module.exports = {
53
53
You can use this package programatically via this exported interface:
54
54
55
55
``` js
56
- export function install (packageName : string )
56
+ export function install (packageName : string , hideUserPrompt : boolean = false )
57
57
```
58
58
59
59
Alternatively, if you want to install dependencies via CLI, this package exposes a bin for that
60
60
61
61
```
62
- Usage: atom-package-deps <directory>
62
+ Usage: atom-package-deps <directory> <hideUserPrompt = true>
63
63
```
64
64
65
65
#### Screenshots
Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ if (process.argv.length !== 3) {
6
6
console . error ( 'Usage: atom-package-deps <directory>' )
7
7
process . exit ( 1 )
8
8
}
9
- const [ , , directory ] = process . argv
9
+ const [ , , directory , hideUserPromptStr ] = process . argv
10
+
11
+ const hideUserPrompt = hideUserPromptStr === 'true'
10
12
11
13
async function main ( ) {
12
14
const resolved = path . resolve ( process . cwd ( ) , directory )
13
- await install ( resolved )
15
+ await install ( resolved , hideUserPrompt )
14
16
console . log ( 'All Done!' )
15
17
}
16
18
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import { DependencyResolved } from './types'
14
14
15
15
type DependenciesResolved = ( DependencyResolved | DependencyResolved [ ] ) [ ]
16
16
17
- export async function install ( packageName : string ) : Promise < void > {
17
+ export async function install ( packageName : string , hideUserPrompt = false ) : Promise < void > {
18
18
invariant ( typeof packageName === 'string' && packageName . length > 0 , '[Package-Deps] Package name is required' )
19
19
20
20
if ( isPackageIgnored ( packageName ) ) {
@@ -60,10 +60,21 @@ export async function install(packageName: string): Promise<void> {
60
60
return
61
61
}
62
62
63
- const chosenDependencies = await confirmPackagesToInstall ( {
64
- packageName,
65
- dependencies : dependenciesToInstall ,
66
- } )
63
+ let chosenDependencies : DependencyResolved [ ]
64
+ if ( ! hideUserPrompt ) {
65
+ chosenDependencies = await confirmPackagesToInstall ( {
66
+ packageName,
67
+ dependencies : dependenciesToInstall ,
68
+ } )
69
+ } else {
70
+ // prompt-less installation
71
+ chosenDependencies = dependenciesToInstall . map ( ( dep ) => {
72
+ if ( Array . isArray ( dep ) ) {
73
+ return dep [ 0 ]
74
+ }
75
+ return dep
76
+ } )
77
+ }
67
78
68
79
if ( chosenDependencies . length === 0 ) {
69
80
// Short-circuit if user interaction cancelled all
You can’t perform that action at this time.
0 commit comments