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');