|
16 | 16 |
|
17 | 17 | if(typeof inFile === "string" && inFile !== '')
|
18 | 18 | {
|
19 |
| - const fileData = fs.readFileSync(inFile, 'utf8'); |
20 |
| - outputJson = JSON.parse(fileData); |
| 19 | + if(fs.existsSync(inFile)) |
| 20 | + { |
| 21 | + const fileData = fs.readFileSync(inFile, 'utf8'); |
| 22 | + outputJson = JSON.parse(fileData); |
| 23 | + } |
| 24 | + else |
| 25 | + core.error("inDirectory " + inDirectory + " does not exist"); |
21 | 26 | }
|
22 | 27 |
|
23 | 28 | if(typeof inDirectory === "string" && inDirectory !== '')
|
24 | 29 | {
|
25 |
| - fs.readdirSync(inDirectory).forEach(filename => { |
26 |
| - if(!filename.endsWith(".json")) |
27 |
| - return; |
28 |
| - |
29 |
| - const filenameWithoutExtension = filename.substring(0, filename.length - ".json".length); |
30 |
| - if(!outputJson.hasOwnProperty(filenameWithoutExtension)) |
31 |
| - { |
32 |
| - core.error(filenameWithoutExtension + " is already defined (in " + inFile + ")"); |
33 |
| - return; |
34 |
| - } |
35 |
| - |
36 |
| - const fileData = fs.readFileSync(inDirectory + '/' + filename, { encoding: 'utf8', flag: 'r' }); |
37 |
| - outputJson[filenameWithoutExtension] = JSON.parse(fileData); |
38 |
| - }); |
| 30 | + if(fs.existsSync(inDirectory)) |
| 31 | + { |
| 32 | + fs.readdirSync(inDirectory).forEach(filename => { |
| 33 | + if (!filename.endsWith(".json")) |
| 34 | + return; |
| 35 | + |
| 36 | + const filenameWithoutExtension = filename.substring(0, filename.length - ".json".length); |
| 37 | + if (!outputJson.hasOwnProperty(filenameWithoutExtension)) { |
| 38 | + core.error(filenameWithoutExtension + " is already defined (in " + inFile + ")"); |
| 39 | + return; |
| 40 | + } |
| 41 | + |
| 42 | + const fileData = fs.readFileSync(inDirectory + '/' + filename, {encoding: 'utf8', flag: 'r'}); |
| 43 | + outputJson[filenameWithoutExtension] = JSON.parse(fileData); |
| 44 | + }); |
| 45 | + } |
| 46 | + else |
| 47 | + core.error("inDirectory " + inDirectory + " does not exist"); |
39 | 48 | }
|
40 | 49 |
|
41 | 50 | if(Object.keys(outputJson).length !== 0)
|
|
0 commit comments