From 6494dfa0abb9b062828dcec78bf9c412e44d84c6 Mon Sep 17 00:00:00 2001 From: Radiantly <44368997+radiantly@users.noreply.github.com> Date: Sun, 19 May 2019 15:12:23 +0530 Subject: [PATCH] fix: coerce python version to semver --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index fa18167..d807880 100644 --- a/index.js +++ b/index.js @@ -7,12 +7,13 @@ const filePath = path.join(__dirname, 'spfcheck2.py'); // ensure python installed if (!which('python')) throw new Error(`Python v2.6+ is required`); -const silent = { silent: true }; +const silent = process.env.NODE_ENV !== 'test'; // ensure python v2.6+ -const version = exec('python --version', silent) - .stderr.split(' ')[1] - .trim(); +let version = exec('python --version', { silent }); +version = semver.coerce( + (version.stdout || version.stderr).split(' ')[1].trim() +); if (!semver.satisfies(version, '>= 2.6')) throw new Error(