nodeshift-archived/centos7-s2i-nodejs

check for "build" script, should also test for the existence of scripts

lholmquist opened this issue · 2 comments

There could be the possibility that a package.json has no scripts property. in this case, our assemble script will fail becuase of this:

https://github.com/bucharest-gold/centos7-s2i-nodejs/blob/master/s2i/assemble#L57

This happened with tests that @bparees is running. I couldn't find the comment, so pasting in the text from the email notifications

@lholmquist
fyi, this started breaking our tests in which we had an empty package.json ("{}"):

 [eval]:1
console.log(require('./package.json').scripts.build ? true : false)
                                             ^

TypeError: Cannot read property 'build' of undefined
    at [eval]:1:46
    at Script.runInThisContext (vm.js:96:20)
    at Object.runInThisContext (vm.js:303:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at evalScript (internal/bootstrap/node.js:582:27)
    at startup (internal/bootstrap/node.js:267:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
subprocess exited with status 1
subprocess exited with status 1

I don't know if that is considered a valid package.json or not, so up to you whether to do something about it, but basically anyone w/ no "scripts" entry is going to hit this i think.

I'm going to close this for now.

If you are using npm init to create your project, a scripts property will be there by default.

if we need to re-open we will