diff --git a/README.md b/README.md index 75d6900..4bb6abb 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,10 @@ include_recipe "nodejs::npm" * use a `String` to specify json file Packages can be installed globally (by default) or in a directory (by using `attribute :path`) + +You can append more specific options to npm command with `attribute :options` array : + * use an array of options (w/ dash), they will be added to npm call. + * ex: `['--production','--force']` or `['--force-latest']` This LWRP try to use npm bare as much as possible (no custom wrapper). diff --git a/providers/npm.rb b/providers/npm.rb index e32bc3c..9940478 100644 --- a/providers/npm.rb +++ b/providers/npm.rb @@ -31,6 +31,9 @@ end def npm_options options = '' options << ' -global' unless new_resource.path + new_resource.options.each do |option| + options << " #{option}" + end options << " #{npm_package}" end diff --git a/resources/npm.rb b/resources/npm.rb index cec789c..f873f93 100644 --- a/resources/npm.rb +++ b/resources/npm.rb @@ -27,6 +27,7 @@ attribute :version, :kind_of => String attribute :path, :kind_of => String attribute :url, :kind_of => String attribute :json, :kind_of => [String, TrueClass] +attribute :options, :kind_of => Array, :default => [] attribute :user, :kind_of => String attribute :group, :kind_of => String diff --git a/test/cookbooks/nodejs_test/recipes/npm.rb b/test/cookbooks/nodejs_test/recipes/npm.rb index 2f9528b..91d1e19 100644 --- a/test/cookbooks/nodejs_test/recipes/npm.rb +++ b/test/cookbooks/nodejs_test/recipes/npm.rb @@ -26,3 +26,7 @@ nodejs_npm 'grunt' do json true user 'random' end + +nodejs_npm 'mocha' do + options ['--force', '--production'] +end