db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 360 forks source link

Error when dependencies attribute not exists in package.json #615

Closed ezequielm closed 5 years ago

ezequielm commented 5 years ago

I'm submitting a...

Current behavior

When you run db-migrate up and the dependencies attribute not exists in package.json, the cli throws this error:

[WARN] TypeError: Cannot convert undefined or null to object
    at Function.assign (<anonymous>)
    at loadPluginList (/Users/ezequielm/Projects/esig/repositories/esignature-email-scheduler/node_modules/db-migrate/index.js:14:20)
    at loadPlugins (/Users/ezequielm/Projects/esig/repositories/esignature-email-scheduler/node_modules/db-migrate/index.js:24:17)
    at Object.module.exports.getInstance (/Users/ezequielm/Projects/esig/repositories/esignature-email-scheduler/node_modules/db-migrate/
index.js:56:51)
    at /Users/ezequielm/Projects/esig/repositories/esignature-email-scheduler/node_modules/db-migrate/bin/db-migrate:32:25
    at /Users/ezequielm/Projects/esig/repositories/esignature-email-scheduler/node_modules/resolve/lib/async.js:65:25
    at ondir (/Users/ezequielm/Projects/esig/repositories/esignature-email-scheduler/node_modules/resolve/lib/async.js:222:27)
    at onex (/Users/ezequielm/Projects/esig/repositories/esignature-email-scheduler/node_modules/resolve/lib/async.js:125:32)

    at /Users/ezequielm/Projects/esig/repositories/esignature-email-scheduler/node_modules/resolve/lib/async.js:11:20
    at FSReqWrap.oncomplete (fs.js:153:5)

Expected behavior

That error shouldn't be showed when dependencies and/or devDependencies attributes not exist in package.json file.

Minimal reproduction of the problem with instructions

  1. Create a new project and run npm init
  2. Install only dev dependencies npm i db-migrate db-migrate-pg -D
  3. Create a migration file: ./node_modules/.bin/db-migrate create add-test-db
  4. Run migrations ./node_modules/.bin/db-migrate up

What is the motivation / use case for changing the behavior?

The warn could be confused since it is displayed when the migration run successfully.

Environment


db-migrate version: 0.11.5
db-migrate driver with versions: pg v7.8.0

Additional information:
- Node version: 8.10
- Platform:  Mac

Others:

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.