Skip to content

Commit

Permalink
Ignore OS-specific files in other operating systems. Fixes #4460
Browse files Browse the repository at this point in the history
  • Loading branch information
bevacqua committed Mar 18, 2016
1 parent ecd13ad commit 79739ab
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
"makelogs": "3.0.0-beta3",
"marked-text-renderer": "0.1.0",
"mocha": "2.3.0",
"ncp": "2.0.0",
"nock": "2.10.0",
"npm": "2.11.0",
"portscanner": "1.0.0",
Expand Down
1 change: 1 addition & 0 deletions tasks/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = function (grunt) {
'stop:optimizeBuild',
'_build:downloadNodeBuilds:finish',
'_build:versionedLinks',
'_build:osShellScripts',
'_build:archives',
grunt.option('os-packages') ? [
'_build:pleaseRun',
Expand Down
42 changes: 42 additions & 0 deletions tasks/build/os_shell_scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {unlink} from 'fs';
import {join, extname} from 'path';
import {promisify} from 'bluebird';
import {ncp} from 'ncp';
const pncp = promisify(ncp);
const punlink = promisify(unlink);

export default function (grunt) {
grunt.registerTask('_build:osShellScripts', async function osShellScripts() {
const done = this.async();
const source = 'build/kibana/bin';
const platforms = grunt.config.get('platforms');
const allPlatforms = fn => invokeAllAsync(platforms, fn);

try {
await allPlatforms(platform => punlink(join(platform.buildDir, 'bin')));
await allPlatforms(platform => pncp(source, join(platform.buildDir, 'bin')));
await allPlatforms(platform => removeExtraneousShellScripts(grunt, platform));
done();
} catch (err) {
done(err);
}
});
};

function invokeAllAsync(all, fn) {
return Promise.all(all.map(fn));
}

function removeExtraneousShellScripts(grunt, platform) {
return Promise.all(grunt.file
.expand(join(platform.buildDir, 'bin', '*'))
.filter(file => isExtraneous(platform, file))
.map(file => punlink(file)));
}

function isExtraneous(platform, file) {
const ext = extname(file);
if (platform.win && ext === '') { return true; }
if (!platform.win && ext === '.bat') { return true; }
return false;
}

0 comments on commit 79739ab

Please sign in to comment.