From 38a703411c7162bfa4d1904ef6b94e2a017ea4da Mon Sep 17 00:00:00 2001 From: Campion Fellin Date: Wed, 25 Nov 2020 08:31:57 -0800 Subject: [PATCH] fix: which command missing for windows (#417) * fix: which command missing for windows Signed-off-by: campionfellin * fix import of os Signed-off-by: campionfellin * fix: strict equality for platform Signed-off-by: campionfellin --- packages/cdk8s-cli/templates/java-app/.hooks.sscaff.js | 3 ++- packages/cdk8s-cli/templates/python-app/.hooks.sscaff.js | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/cdk8s-cli/templates/java-app/.hooks.sscaff.js b/packages/cdk8s-cli/templates/java-app/.hooks.sscaff.js index 3d10245ab0..c07a9a93f0 100644 --- a/packages/cdk8s-cli/templates/java-app/.hooks.sscaff.js +++ b/packages/cdk8s-cli/templates/java-app/.hooks.sscaff.js @@ -1,11 +1,12 @@ const { execSync } = require('child_process'); const { readFileSync } = require('fs'); +const { platform } = require('os'); const cli = require.resolve('../../bin/cdk8s'); exports.pre = (variables) => { try { - execSync('which mvn'); + execSync(`${platform() === 'win32' ? 'where' : 'which'} mvn`); } catch { console.error(`Unable to find "mvn". Install from https://maven.apache.org/install.html`); process.exit(1); diff --git a/packages/cdk8s-cli/templates/python-app/.hooks.sscaff.js b/packages/cdk8s-cli/templates/python-app/.hooks.sscaff.js index 23d1e56108..906a1aa9f0 100644 --- a/packages/cdk8s-cli/templates/python-app/.hooks.sscaff.js +++ b/packages/cdk8s-cli/templates/python-app/.hooks.sscaff.js @@ -1,20 +1,21 @@ const { execSync } = require('child_process'); const { chmodSync } = require('fs'); const { readFileSync } = require('fs'); +const { platform } = require('os'); const cli = require.resolve('../../bin/cdk8s'); exports.pre = () => { try { - execSync('which pipenv') + execSync(`${platform() === 'win32' ? 'where' : 'which'} pipenv`); } catch { - console.error(`Unable to find "pipenv". Install from https://pipenv.kennethreitz.org`) + console.error(`Unable to find "pipenv". Install from https://pipenv.kennethreitz.org`); process.exit(1); } try { - execSync('which pip3') + execSync(`${platform() === 'win32' ? 'where' : 'which'} pip3`); } catch { - console.error(`Unable to find "pip3". Install from https://pip.pypa.io`) + console.error(`Unable to find "pip3". Install from https://pip.pypa.io`); process.exit(1); } };