@@ -20,6 +20,31 @@ configFile=''
20
20
# Helper functions
21
21
#
22
22
23
+ # Copies a config file to a directory, giving it a unique name, and prints out
24
+ # the full path.
25
+ function copy-config-file {
26
+ local srcPath=" $1 "
27
+ local destDir=" $2 "
28
+
29
+ local baseName=" $( basename " ${srcPath} " ) "
30
+ local prefix=" $( date +%s) "
31
+ (( prefix = (prefix + $$ ) % 10000 ))
32
+
33
+ local destPath
34
+ while true ; do
35
+ destPath=" ${destDir} /${prefix} -${baseName} "
36
+ if [[ ! -x " ${destPath} " ]]; then
37
+ break
38
+ fi
39
+ (( prefix++ ))
40
+ done
41
+
42
+ cp " ${srcPath} " " ${destPath} " \
43
+ || return " $? "
44
+
45
+ echo " ${destPath} "
46
+ }
47
+
23
48
# Finds the argument which specifies the config file, stashes it in a global
24
49
# as an absolute path, and drops it from the arguments.
25
50
function find-config-arg {
@@ -73,19 +98,12 @@ if [[ ${configFile} =~ (^|/)eslint[.]config[.] ]]; then
73
98
srcDir=" $( dirname " ${configFile} " ) "
74
99
cd " ${srcDir} "
75
100
76
- # TEMP: Should do this in a concurrent-safe way.
77
- newConfigFile= " ${baseDir} /lib/ $( basename " ${configFile} " ) "
78
- cp " ${configFile} " " ${newConfigFile} "
101
+ newConfigFile= " $( copy-config-file " ${configFile} " " ${baseDir} /lib " ) " \
102
+ || exit " $? "
103
+ trap " rm -rf \ "${newConfigFile} \" " EXIT
79
104
80
- echo \
81
105
ESLINT_USE_FLAT_CONFIG=true \
82
- exec " ${baseDir} /lib/node_modules/.bin/eslint" \
83
- --cache --cache-location " ${baseDir} /cache" \
84
- --config " ${newConfigFile} " \
85
- " ${args[@]} "
86
-
87
- ESLINT_USE_FLAT_CONFIG=true \
88
- exec " ${baseDir} /lib/node_modules/.bin/eslint" \
106
+ " ${baseDir} /lib/node_modules/.bin/eslint" \
89
107
--cache --cache-location " ${baseDir} /cache" \
90
108
--config " ${newConfigFile} " \
91
109
" ${args[@]} "
0 commit comments