mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Fix running tasks on Windows (elastic/kibana-plugin-helpers#37)
* create windows cmd wrapper * use windows cmd wrapper on browser tests * be explicit about the mocha command location * use windows cmd wrapper on server tests * use windows cmd wrapper on build default to using npm as well Original commit: elastic/kibana-plugin-helpers@35f80a08ce
This commit is contained in:
parent
142d2dff2d
commit
a773536c06
4 changed files with 15 additions and 4 deletions
5
packages/kbn-plugin-helpers/lib/win_cmd.js
Normal file
5
packages/kbn-plugin-helpers/lib/win_cmd.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
var platform = require('os').platform();
|
||||
|
||||
module.exports = function winCmd(cmd) {
|
||||
return /^win/.test(platform) ? cmd + '.cmd' : cmd;
|
||||
};
|
|
@ -8,6 +8,7 @@ var rename = require('gulp-rename');
|
|||
|
||||
var rewritePackageJson = require('./rewrite_package_json');
|
||||
var gitInfo = require('./git_info');
|
||||
var winCmd = require('../../lib/win_cmd');
|
||||
|
||||
module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaVersion, files) {
|
||||
var buildSource = plugin.root;
|
||||
|
@ -34,6 +35,7 @@ module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaV
|
|||
})
|
||||
.then(function () {
|
||||
// install packages in build
|
||||
var cmd = winCmd('npm');
|
||||
var options = {
|
||||
cwd: buildRoot,
|
||||
stdio: ['ignore', 'ignore', 'pipe'],
|
||||
|
@ -41,11 +43,12 @@ module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaV
|
|||
|
||||
try {
|
||||
// use yarn if yarn lockfile is found in the build
|
||||
cmd = winCmd('yarn');
|
||||
statSync(join(buildRoot, 'yarn.lock'));
|
||||
execFileSync('yarn', ['install', '--production'], options);
|
||||
execFileSync(cmd, ['install', '--production'], options);
|
||||
} catch (e) {
|
||||
// use npm if there is no yarn lockfile in the build
|
||||
execFileSync('npm', ['install', '--production', '--no-bin-links'], options);
|
||||
execFileSync(cmd, ['install', '--production', '--no-bin-links'], options);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var execFileSync = require('child_process').execFileSync;
|
||||
var winCmd = require('../../../lib/win_cmd');
|
||||
|
||||
module.exports = function testBrowserAction(plugin, run, options) {
|
||||
options = options || {};
|
||||
|
@ -13,7 +14,7 @@ module.exports = function testBrowserAction(plugin, run, options) {
|
|||
kbnServerArgs.push('--kbnServer.tests_bundle.pluginId=' + plugin.id);
|
||||
}
|
||||
|
||||
var cmd = 'npm';
|
||||
var cmd = winCmd('npm');
|
||||
var task = (options.dev) ? 'test:dev' : 'test:browser';
|
||||
var args = ['run', task, '--'].concat(kbnServerArgs);
|
||||
execFileSync(cmd, args, {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var resolve = require('path').resolve;
|
||||
var delimiter = require('path').delimiter;
|
||||
var execFileSync = require('child_process').execFileSync;
|
||||
var winCmd = require('../../../lib/win_cmd');
|
||||
|
||||
module.exports = function (plugin, run, options) {
|
||||
options = options || {};
|
||||
|
@ -13,7 +14,8 @@ module.exports = function (plugin, run, options) {
|
|||
testPaths = options.files;
|
||||
}
|
||||
|
||||
var cmd = 'mocha';
|
||||
var fullCmd = resolve(plugin.kibanaRoot, 'node_modules', '.bin', 'mocha');
|
||||
var cmd = winCmd(fullCmd);
|
||||
var args = ['--require', mochaSetupJs].concat(testPaths);
|
||||
var path = `${kibanaBins}${delimiter}${process.env.PATH}`;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue