Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow loading multiple ENV files #77

Closed
wants to merge 3 commits into from

Conversation

joeyespo
Copy link
Contributor

This is to match the way Foreman works.

@slnode
Copy link

slnode commented Oct 26, 2015

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@rmg
Copy link
Member

rmg commented Oct 26, 2015

@slnode ok to test

@@ -138,6 +139,20 @@ function loadEnvs(path) {
return env;
}

function loadEnvs(path) {
if (path.indexOf(',') === -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? I think path.split(',') below will handle this case as a single item Array and "just work", won't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct. Was keeping the existing behavior when there's no ',' for a slight performance gain. It's negligible though, so I can remove it if that's preferred.

@rmg
Copy link
Member

rmg commented Oct 26, 2015

@joeyespo thanks for the pull request!

Is there any chance you could update the help message to indicate the added support for a comma separated list? And address my comments, if you don't mind.

@joeyespo
Copy link
Contributor Author

@rmg Sure, will do!

@joeyespo
Copy link
Contributor Author

@rmg Updated in 85901d1.

@joeyespo
Copy link
Contributor Author

@rmg Any idea what's up with these test failures? My initial commit passed, now there's a bunch of failed linting errors from what I could see. Looks like they might be from generated .js in test/.

@rmg
Copy link
Member

rmg commented Oct 27, 2015

It's the env tests, all the keys are now in a different order than the fixtures. Hm...

@joeyespo
Copy link
Contributor Author

@rmg Closing and re-opening to see if a fresh PR will fix the tests.

@joeyespo joeyespo closed this Oct 27, 2015
@joeyespo
Copy link
Contributor Author

@rmg #78 is the new PR. Looks like that didn't help though, they failed right away.

Anything you need me to do?

@joeyespo joeyespo mentioned this pull request Oct 27, 2015
@joeyespo joeyespo reopened this Oct 27, 2015
@slnode
Copy link

slnode commented Oct 27, 2015

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@rmg
Copy link
Member

rmg commented Oct 27, 2015

@slnode ok to test

@rmg
Copy link
Member

rmg commented Oct 27, 2015

@joeyespo do the tests pass for you locally when you run npm test?

@joeyespo
Copy link
Contributor Author

@rmg Here's my npm test output:

node-foreman>npm run test

> foreman@1.4.1 test node-foreman
> tap test

total ................................................... 0/0

ok

@rmg
Copy link
Member

rmg commented Oct 27, 2015

@joeyespo I just merged #79 to hopefully help with the tests a little bit. Could you try rebasing your branch on the current master and seeing if the tests work any better for you?

@joeyespo
Copy link
Contributor Author

@rmg Done.

@rmg
Copy link
Member

rmg commented Oct 27, 2015

@joeyespo do the tests give you anything more useful when you run them locally now? You'll need to do npm update to get the newer tap release.

@joeyespo
Copy link
Contributor Author

@rmg Getting the following output now, both on master and on multiple-env-files. (I pulled latest and ran npm update first.)

bash-4.3$ npm run test

> foreman@1.4.1 pretest node-foreman
> jshint *.js lib/*.js

ERROR: Can't open *.js
ERROR: Can't open lib/*.js

> foreman@1.4.1 test node-foreman
> tap test/*.test.*

ok test/console-output.test.js .......................... 1/1
ok test/console-trim.test.js ............................ 1/1
ok test/envs-commented.test.js .......................... 1/1
ok test/envs-empty.test.js .............................. 1/1
ok test/envs-json.test.js ............................... 1/1
ok test/envs-quoted.test.js ............................. 1/1

assert.js:89
  throw new assert.AssertionError({
  ^
AssertionError: false == true
    at process.<anonymous> (node-foreman\test\run-once.test.js:29:12)
    at emitOne (events.js:77:13)
    at process.emit (events.js:169:7)
not ok test/run-once.test.js ............................ 0/1
    Command: "C:\Program Files\nodejs\node.exe run-once.test.js"
    TAP version 13
    not ok 1 test/run-once.test.js
      ---
        exit:    1
        stderr:  |
          assert.js:89
            throw new assert.AssertionError({
            ^
          AssertionError: false == true
              at process.<anonymous> (node-foreman\test\run-once.test.js:29:12)
              at emitOne (events.js:77:13)
              at process.emit (events.js:169:7)
        command: |
          "C:\Program Files\nodejs\node.exe run-once.test.js"
      ...

    1..1
    # tests 1
    # fail  1

total ................................................... 6/7

not ok

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
npm ERR! node v4.1.0
npm ERR! npm  v2.14.3
npm ERR! code ELIFECYCLE
npm ERR! foreman@1.4.1 test: `tap test/*.test.*`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the foreman@1.4.1 test script 'tap test/*.test.*'.
npm ERR! This is most likely a problem with the foreman package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tap test/*.test.*
npm ERR! You can get their info via:
npm ERR!     npm owner ls foreman
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     node-foreman\npm-debug.log

On Windows though, so I had to run within git's bash. I noticed that once starts a process in a cross-platform way, but the test doesn't. So changing $FILENAME to %FILENAME%" produces:

bash-4.3$ npm run test

> foreman@1.4.1 pretest node-foreman
> jshint *.js lib/*.js

ERROR: Can't open *.js
ERROR: Can't open lib/*.js

> foreman@1.4.1 test node-foreman
> tap test/*.test.*

ok test/console-output.test.js .......................... 1/1
ok test/console-trim.test.js ............................ 1/1
ok test/envs-commented.test.js .......................... 1/1
ok test/envs-empty.test.js .............................. 1/1
ok test/envs-json.test.js ............................... 1/1
ok test/envs-quoted.test.js ............................. 1/1
ok test/run-once.test.js ................................ 1/1
total ................................................... 7/7

ok

Looks like the tests are passing locally.

While I'm at it, want me to make run-once.test.js cross-platform (when run within bash) in a separate PR?

@rmg
Copy link
Member

rmg commented Oct 28, 2015

Ah, right.. Windows wouldn't recognize all the tests that are actually shell scripts. Might need to port those to node to make them more portable.

@joeyespo
Copy link
Contributor Author

@rmg Let me know what else you need from me.

@glennr
Copy link

glennr commented Dec 17, 2015

+1 for this feature

@glennr
Copy link

glennr commented Dec 17, 2015

nevermind - I see this works if you supply the -e flag to the nf command directly.

e.g.

nf -e .env.test start -s

Nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants