-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathresolve.js
executable file
·39 lines (36 loc) · 1.23 KB
/
resolve.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
const isCi = require('@npmcli/ci-detect')();
const pkgFacade = require('./src/pkgFacade');
const view = require('./src/views/general')
const argv = require('./src/arguments').get();
const auditResolver = require('./src/resolve/auditResolver')
if (isCi && !argv.trustmeitsnotci) {
view.ciDetected()
process.exit(1)
}
if (argv.yarn) {
pkgFacade.addImplementation('yarn', require('./src/pkgmanagers/yarn'))
pkgFacade.setActiveImplementation('yarn')
} else if (argv["yarn-berry"]) {
pkgFacade.addImplementation('yarn-berry', require('./src/pkgmanagers/yarnBerry'))
pkgFacade.setActiveImplementation('yarn-berry')
} else {
pkgFacade.addImplementation('npm', require('./src/pkgmanagers/npm'))
pkgFacade.setActiveImplementation('npm')
}
pkgFacade.getAudit({ shellOptions: { ignoreExit: true } })
.then(async input => {
const choice = await auditResolver.askForFix(input)
if (choice === 'f') {
return pkgFacade.getAudit({ shellOptions: { ignoreExit: true } })
} else {
return input
}
})
.then(input => {
return auditResolver.askForResolutions(input)
})
.catch(e => {
view.genericError(e);
process.exit(2);
});