sanathkr / go-npm

Distribute and install Go binaries via NPM
Apache License 2.0
171 stars 56 forks source link

judge the warning as error #17

Open oneslideicywater opened 2 years ago

oneslideicywater commented 2 years ago

there's in a situation, npm bin print some warning msg such as:

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.  // stderr
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.  // stderr
C:\Users\john\AppData\Roaming\npm  //stdout

but your source code:

exec("npm bin -g", function(err, stdout, stderr) {

        let dir =  null;
        if (err || stderr || !stdout || stdout.length === 0)  {

            //   npm bin successfully print npm bin path with some warnings, but program goes to this branch.
            let env = process.env;
            if (env && env.npm_config_prefix) {
                dir = path.join(env.npm_config_prefix, "bin");
            }
        } else {
            dir = stdout.trim();
        }
        console.log(dir)

});