GUACAMOLE-1859: Ensure "dist" directory exists prior to enumerating NPM dependencies.

This commit is contained in:
Mike Jumper
2023-10-04 16:30:38 -07:00
parent 99344359f0
commit f82cc93414

View File

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