From 2e0c521a8cf7e9b8a37345132442f8830b565055 Mon Sep 17 00:00:00 2001 From: Oleg Andreyev Date: Mon, 24 Feb 2020 16:48:00 +0200 Subject: [PATCH 1/2] inheriting from webpack context if it's not defined + parseInt for maxBuffer --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index a90c75e..15db019 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,15 @@ const loaderUtils = require('loader-utils'); module.exports = function(source) { const callback = this.async(); const { script, ...options } = loaderUtils.getOptions(this); + + if (!options.cwd) { + options.cwd = this.context; + } + + if (options.maxBuffer) { + options.maxBuffer = parseInt(options.maxBuffer); + } + const command = exec(script, options, function(err, result) { if (err) return callback(err); callback(null, result); From a3dd294b2c882768b9d1c491874594d6dd7cc411 Mon Sep 17 00:00:00 2001 From: Oleg Andreyev Date: Tue, 12 Jan 2021 20:26:16 +0200 Subject: [PATCH 2/2] added throw new Error instead of callback(err) --- index.js | 5 ++++- package-lock.json | 6 +++--- package.json | 3 --- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 15db019..000db45 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,10 @@ module.exports = function(source) { } const command = exec(script, options, function(err, result) { - if (err) return callback(err); + if (err) { + throw new Error(err); + } + callback(null, result); }); command.stdin.write(source); diff --git a/package-lock.json b/package-lock.json index e9c50ef..dd2ca2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,9 +33,9 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" } } } diff --git a/package.json b/package.json index a4e70a2..84ac040 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,6 @@ "shell-script" ], "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, "repository": { "type": "git", "url": "https://github.com/localjo/shell-loader.git"