17
17
18
18
/* eslint-disable @backstage/no-undeclared-imports */
19
19
20
- import { execFile as execFileCb } from " child_process" ;
21
- import { resolve as resolvePath , dirname as dirnamePath } from " path" ;
22
- import { promisify } from " util" ;
20
+ import { execFile as execFileCb } from ' child_process' ;
21
+ import { resolve as resolvePath , dirname as dirnamePath } from ' path' ;
22
+ import { promisify } from ' util' ;
23
23
24
24
const execFile = promisify ( execFileCb ) ;
25
25
26
26
async function findLockFiles ( ) {
27
27
// Not using relative paths as this should be run inside a workspace folder
28
- const projectRoot = resolvePath ( "." ) ;
28
+ const projectRoot = resolvePath ( '.' ) ;
29
29
30
- let files = process . argv . slice ( 2 ) . filter ( ( arg ) => ! arg . startsWith ( "--" ) ) ;
30
+ let files = process . argv . slice ( 2 ) . filter ( arg => ! arg . startsWith ( '--' ) ) ;
31
31
32
32
for ( const argumentFile of files ) {
33
33
if ( ! argumentFile . match ( / (?: ^ | [ \/ \\ ] ) y a r n .l o c k $ / ) ) {
@@ -37,10 +37,10 @@ async function findLockFiles() {
37
37
38
38
if ( ! files . length ) {
39
39
// List all lock files that are in the root or in an immediate subdirectory
40
- files = [ " yarn.lock" ] ;
40
+ files = [ ' yarn.lock' ] ;
41
41
}
42
42
43
- return files . map ( ( file ) => ( {
43
+ return files . map ( file => ( {
44
44
fileRelativeToProjectRoot : file ,
45
45
directoryRelativeToProjectRoot : dirnamePath ( file ) ,
46
46
directoryAbsolute : resolvePath ( projectRoot , dirnamePath ( file ) ) ,
@@ -52,8 +52,8 @@ async function main() {
52
52
53
53
let fix = false ;
54
54
for ( const arg of process . argv ) {
55
- if ( arg . startsWith ( "--" ) ) {
56
- if ( arg === " --fix" ) {
55
+ if ( arg . startsWith ( '--' ) ) {
56
+ if ( arg === ' --fix' ) {
57
57
fix = true ;
58
58
} else {
59
59
throw new Error ( `Unknown argument ${ arg } ` ) ;
@@ -62,20 +62,20 @@ async function main() {
62
62
}
63
63
64
64
for ( const lockFile of lockFiles ) {
65
- console . log ( " Checking lock file" , lockFile . fileRelativeToProjectRoot ) ;
65
+ console . log ( ' Checking lock file' , lockFile . fileRelativeToProjectRoot ) ;
66
66
67
67
let stdout ;
68
68
let stderr ;
69
69
let failed ;
70
70
71
71
try {
72
72
const result = await execFile (
73
- " yarn" ,
74
- [ " dedupe" , ...( fix ? [ ] : [ " --check" ] ) ] ,
73
+ ' yarn' ,
74
+ [ ' dedupe' , ...( fix ? [ ] : [ ' --check' ] ) ] ,
75
75
{
76
76
shell : true ,
77
77
cwd : lockFile . directoryAbsolute ,
78
- }
78
+ } ,
79
79
) ;
80
80
stdout = result . stdout ?. trim ( ) ;
81
81
stderr = result . stderr ?. trim ( ) ;
@@ -97,40 +97,40 @@ async function main() {
97
97
if ( failed ) {
98
98
if ( ! fix ) {
99
99
const command = `yarn${
100
- lockFile . directoryRelativeToProjectRoot === "."
101
- ? ""
100
+ lockFile . directoryRelativeToProjectRoot === '.'
101
+ ? ''
102
102
: ` --cwd ${ lockFile . directoryRelativeToProjectRoot } `
103
103
} dedupe`;
104
- const padding = " " . repeat ( Math . max ( 0 , 85 - 6 - command . length ) ) ;
105
- console . error ( "" ) ;
104
+ const padding = ' ' . repeat ( Math . max ( 0 , 85 - 6 - command . length ) ) ;
105
+ console . error ( '' ) ;
106
106
console . error (
107
- " *************************************************************************************"
107
+ ' *************************************************************************************' ,
108
108
) ;
109
109
console . error (
110
- " * You have duplicate versions of some packages in a yarn.lock file. *"
110
+ ' * You have duplicate versions of some packages in a yarn.lock file. *' ,
111
111
) ;
112
112
console . error (
113
- " * To solve this, run the following command from the project root and commit all *"
113
+ ' * To solve this, run the following command from the project root and commit all *' ,
114
114
) ;
115
115
console . log (
116
- " * yarn.lock changes. *"
116
+ ' * yarn.lock changes. *' ,
117
117
) ;
118
118
console . log (
119
- " * *"
119
+ ' * *' ,
120
120
) ;
121
121
console . log ( `* ${ command } ${ padding } *` ) ;
122
122
console . error (
123
- " *************************************************************************************"
123
+ ' *************************************************************************************' ,
124
124
) ;
125
- console . error ( "" ) ;
125
+ console . error ( '' ) ;
126
126
}
127
127
128
128
process . exit ( 1 ) ;
129
129
}
130
130
}
131
131
}
132
132
133
- main ( ) . catch ( ( error ) => {
133
+ main ( ) . catch ( error => {
134
134
console . error ( error . stack ) ;
135
135
process . exit ( 1 ) ;
136
136
} ) ;
0 commit comments