Skip to content

Commit

Permalink
Rebuild modulePath correctly if on Windows (elastic#11439)
Browse files Browse the repository at this point in the history
The module paths are split by ':' and with a Windows filepath (and the 'C:/' prefix),
the split returns the drive letter and directory path separately.
This causes the modulePath to be set incorrectly into the packagePaths object
and the subsequent call for the licenses by key returns undefined on Windows only.

This commit recombines the drive and directory paths and sets the correct key into packagePaths.
  • Loading branch information
colmose authored and jbudz committed May 10, 2017
1 parent 8167449 commit a20d14f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tasks/build/notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ export default function licenses(grunt) {
cwd: buildPath
});
installedPackages.toString().trim().split('\n').forEach(pkg => {
let modulePath;
let dirPath;
let packageName;
let drive;
const packageDetails = pkg.split(':');
const [modulePath, packageName] = packageDetails;
if (/^win/.test(process.platform)) {
[drive, dirPath, packageName] = packageDetails;
modulePath = `${drive}:${dirPath}`;
} else {
[modulePath, packageName] = packageDetails;
}
const licenses = glob.sync(path.join(modulePath, '*LICENSE*'));
const notices = glob.sync(path.join(modulePath, '*NOTICE*'));
packagePaths[packageName] = {
relative: modulePath.replace(/.*\/kibana\//, ''),
relative: modulePath.replace(/.*(\/|\\)kibana(\/|\\)/, ''),
licenses,
notices
};
Expand Down

0 comments on commit a20d14f

Please sign in to comment.