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

Add option node_modules for node.js builds #1263

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/travis/build/script/node_js.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class NodeJs < Script

NPM_QUIET_TREE_VERSION = '5'

DEFAULTS = {
node_modules: true
}

def export
super
if node_js_given_in_config?
Expand All @@ -17,7 +21,7 @@ def export

def setup
super
prepend_path './node_modules/.bin'
prepend_path './node_modules/.bin' if config[:node_modules]
convert_legacy_nodejs_config
update_nvm
nvm_install
Expand Down
21 changes: 21 additions & 0 deletions spec/build/script/node_js_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,27 @@
expect(sexp).to include_sexp [:export, ['TRAVIS_NODE_VERSION', '0.10']]
end
end

end
end

describe 'PATH manipulation' do
let(:sexp) { sexp_find(subject, [:if, "$(echo :$PATH: | grep -v :./node_modules/.bin:)"]) }

context "when node_modules option is not set" do
it 'does adds "./node_modules/.bin" to PATH' do
expect(sexp).to include_sexp [:export, ['PATH', "./node_modules/.bin:$PATH"], echo: true]
end
end

context "when node_modules option is set to false" do
before :each do
data[:config][:node_modules] = false
end

it 'does not add "./node_modules/.bin" to PATH' do
expect(sexp).not_to include_sexp [:export, ['PATH', "./node_modules/.bin:$PATH"], echo: true]
end
end
end

Expand Down