Rebuild modulePath correctly if on Windows (#11439) (#11690)

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.
This commit is contained in:
Jonathan Budzenski 2017-05-10 09:04:14 -05:00 committed by GitHub
parent 8167449c99
commit 2e4aabd65b

View file

@ -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
};