diff --git a/index.js b/index.js index a90c75e..000db45 100644 --- a/index.js +++ b/index.js @@ -4,8 +4,20 @@ 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); + 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"