From a20d14f1497377c00838f17d93150be173c74d8a Mon Sep 17 00:00:00 2001 From: Colm O'Shea Date: Wed, 10 May 2017 12:25:23 +0100 Subject: [PATCH] Rebuild modulePath correctly if on Windows (#11439) 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. --- tasks/build/notice.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tasks/build/notice.js b/tasks/build/notice.js index 8523462bc82dc1..825a390219e676 100644 --- a/tasks/build/notice.js +++ b/tasks/build/notice.js @@ -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 };