2019-01-12 11:33:27 +08:00
|
|
|
'use strict';
|
2018-03-18 19:59:38 +08:00
|
|
|
|
|
|
|
// NOTE: the following code was partially adopted from https://github.com/iarna/in-publish
|
2019-01-12 11:33:27 +08:00
|
|
|
module.exports = function getNpmArgs() {
|
|
|
|
let npmArgv = null;
|
2018-03-18 19:59:38 +08:00
|
|
|
|
|
|
|
try {
|
2019-01-12 11:33:27 +08:00
|
|
|
npmArgv = JSON.parse(process.env.npm_config_argv);
|
2018-03-18 19:59:38 +08:00
|
|
|
} catch (err) {
|
2019-01-12 11:33:27 +08:00
|
|
|
return null;
|
2018-03-18 19:59:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof npmArgv !== 'object' || !npmArgv.cooked || !Array.isArray(npmArgv.cooked)) {
|
2019-01-12 11:33:27 +08:00
|
|
|
return null;
|
2018-03-18 19:59:38 +08:00
|
|
|
}
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
return npmArgv.cooked;
|
|
|
|
};
|