From f82cc93414ce3040784017f09923ec3efe5ca917 Mon Sep 17 00:00:00 2001 From: Mike Jumper Date: Wed, 4 Oct 2023 16:30:38 -0700 Subject: [PATCH] GUACAMOLE-1859: Ensure "dist" directory exists prior to enumerating NPM dependencies. --- .../main/frontend/plugins/dependency-list-plugin.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/frontend/plugins/dependency-list-plugin.js b/guacamole/src/main/frontend/plugins/dependency-list-plugin.js index 3fd62caaf..2dfaa0061 100644 --- a/guacamole/src/main/frontend/plugins/dependency-list-plugin.js +++ b/guacamole/src/main/frontend/plugins/dependency-list-plugin.js @@ -91,6 +91,13 @@ class DependencyListPlugin { */ const logger = compiler.getInfrastructureLogger(PLUGIN_NAME); + /** + * The directory receiving the dependency list file. + * + * @type {string} + */ + const outputPath = this.options.path || compiler.options.output.path; + /** * The full path to the output file that should contain the list of * discovered NPM module dependencies. @@ -98,7 +105,7 @@ class DependencyListPlugin { * @type {string} */ const outputFile = path.join( - this.options.path || compiler.options.output.path, + outputPath, this.options.filename || 'npm-dependencies.txt' ); @@ -132,6 +139,10 @@ class DependencyListPlugin { }); + // Create output path if it doesn't yet exist + if (!fs.existsSync(outputPath)) + fs.mkdirSync(outputPath, { recursive: true, mode: 0o755 }); + // Write all discovered NPM packages to configured output file const sortedCoords = Object.keys(moduleCoords).sort(); fs.writeFileSync(outputFile, sortedCoords.join('\n') + '\n');