webpacker 5.1.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +8 -8
  3. data/.github/workflows/jest.yml +38 -0
  4. data/.github/workflows/js-lint.yml +39 -0
  5. data/.github/workflows/rubocop.yml +39 -0
  6. data/.github/workflows/ruby.yml +66 -0
  7. data/.node-version +1 -1
  8. data/.rubocop.yml +113 -13
  9. data/CHANGELOG.md +27 -2
  10. data/Gemfile.lock +112 -103
  11. data/README.md +11 -19
  12. data/docs/css.md +58 -3
  13. data/docs/integrations.md +1 -1
  14. data/docs/target.md +22 -0
  15. data/docs/testing.md +1 -1
  16. data/docs/troubleshooting.md +3 -1
  17. data/docs/typescript.md +89 -8
  18. data/docs/webpack-dev-server.md +1 -1
  19. data/lib/install/config/babel.config.js +1 -3
  20. data/lib/install/config/webpacker.yml +1 -1
  21. data/lib/install/template.rb +9 -1
  22. data/lib/install/typescript.rb +2 -5
  23. data/lib/tasks/webpacker/check_node.rake +1 -1
  24. data/lib/tasks/webpacker/check_yarn.rake +2 -3
  25. data/lib/tasks/webpacker/yarn_install.rake +7 -1
  26. data/lib/webpacker/commands.rb +1 -1
  27. data/lib/webpacker/compiler.rb +7 -2
  28. data/lib/webpacker/configuration.rb +12 -4
  29. data/lib/webpacker/dev_server_runner.rb +2 -2
  30. data/lib/webpacker/helper.rb +29 -10
  31. data/lib/webpacker/runner.rb +1 -0
  32. data/lib/webpacker/version.rb +1 -1
  33. data/lib/webpacker/webpack_runner.rb +2 -2
  34. data/package.json +35 -35
  35. data/package/__tests__/config.js +12 -1
  36. data/package/__tests__/development.js +14 -1
  37. data/package/config.js +4 -1
  38. data/package/configPath.js +3 -0
  39. data/package/env.js +1 -2
  40. data/package/environments/__tests__/base.js +25 -8
  41. data/package/environments/base.js +5 -6
  42. data/package/environments/development.js +39 -33
  43. data/package/environments/production.js +1 -3
  44. data/package/rules/babel.js +11 -4
  45. data/package/rules/file.js +3 -2
  46. data/package/rules/node_modules.js +1 -3
  47. data/package/rules/sass.js +4 -1
  48. data/package/utils/helpers.js +1 -1
  49. data/test/compiler_test.rb +8 -3
  50. data/test/configuration_test.rb +8 -7
  51. data/test/dev_server_runner_test.rb +1 -1
  52. data/test/helper_test.rb +3 -0
  53. data/test/test_app/config/webpacker.yml +7 -1
  54. data/test/test_app/public/packs/manifest.json +1 -0
  55. data/test/webpack_runner_test.rb +1 -1
  56. data/webpacker.gemspec +1 -1
  57. data/yarn.lock +3290 -3588
  58. metadata +19 -13
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Webpacker
2
2
 
3
3
  [![Build Status](https://travis-ci.org/rails/webpacker.svg?branch=master)](https://travis-ci.org/rails/webpacker)
4
- [![node.js](https://img.shields.io/badge/node-%3E%3D%2010.13.0-brightgreen.svg)](https://www.npmjs.com/package/@rails/webpacker)
4
+ [![node.js](https://img.shields.io/badge/node-%3E%3D%2010.17.0-brightgreen.svg)](https://www.npmjs.com/package/@rails/webpacker)
5
5
  [![Gem](https://img.shields.io/gem/v/webpacker.svg)](https://rubygems.org/gems/webpacker)
6
6
 
7
7
  Webpacker makes it easy to use the JavaScript pre-processor and bundler
@@ -35,6 +35,7 @@ in which case you may not even need the asset pipeline. This is mostly relevant
35
35
  - [Elm](./docs/integrations.md#elm)
36
36
  - [Stimulus](./docs/integrations.md#stimulus)
37
37
  - [Svelte](./docs/integrations.md#svelte)
38
+ - [Typescript](./docs/typescript.md)
38
39
  - [CoffeeScript](./docs/integrations.md#coffeescript)
39
40
  - [Erb](./docs/integrations.md#erb)
40
41
  - [Paths](#paths)
@@ -51,7 +52,7 @@ in which case you may not even need the asset pipeline. This is mostly relevant
51
52
 
52
53
  - Ruby 2.4+
53
54
  - Rails 5.2+
54
- - Node.js 10.13.0+
55
+ - Node.js 10.17.0+
55
56
  - Yarn 1.x+
56
57
 
57
58
  ## Features
@@ -121,8 +122,11 @@ app/javascript:
121
122
  ├── packs:
122
123
  │ # only webpack entry files here
123
124
  │ └── application.js
124
- └── src:
125
125
  │ └── application.css
126
+ └── src:
127
+ │ └── my_component.js
128
+ └── stylesheets:
129
+ │ └── my_styles.css
126
130
  └── images:
127
131
  └── logo.svg
128
132
  ```
@@ -318,7 +322,7 @@ Included install integrations:
318
322
  - [Svelte](./docs/integrations.md#Svelte)
319
323
  - [Stimulus](./docs/integrations.md#Stimulus)
320
324
  - [CoffeeScript](./docs/integrations.md#CoffeeScript)
321
- - [Typescript](./docs/integrations.md)
325
+ - [Typescript](./docs/typescript.md)
322
326
  - [Erb](./docs/integrations.md#Erb)
323
327
 
324
328
  See [Integrations](./docs/integrations.md) for further details.
@@ -362,12 +366,12 @@ If you have `hmr` turned to true, then the `stylesheet_pack_tag` generates no ou
362
366
 
363
367
  If you are adding Webpacker to an existing app that has most of the assets inside
364
368
  `app/assets` or inside an engine, and you want to share that
365
- with webpack modules, you can use the `resolved_paths`
369
+ with webpack modules, you can use the `additional_paths`
366
370
  option available in `config/webpacker.yml`. This lets you
367
371
  add additional paths that webpack should lookup when resolving modules:
368
372
 
369
373
  ```yml
370
- resolved_paths: ['app/assets']
374
+ additional_paths: ['app/assets']
371
375
  ```
372
376
 
373
377
  You can then import these items inside your modules like so:
@@ -382,18 +386,6 @@ import 'images/rails.png'
382
386
  will make the compilation slow, consider adding specific paths instead of
383
387
  whole parent directory if you just need to reference one or two modules
384
388
 
385
- ### Watched
386
-
387
- By default, the lazy compilation is cached until a file is changed under your
388
- tracked paths. You can configure which paths are tracked
389
- by adding new paths to `watched_paths` array. This is much like Rails' `autoload_paths`:
390
-
391
- ```rb
392
- # config/initializers/webpacker.rb
393
- # or config/application.rb
394
- Webpacker::Compiler.watched_paths << 'bower_components'
395
- ```
396
-
397
389
  ## Deployment
398
390
 
399
391
  Webpacker hooks up a new `webpacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`. If you are not using Sprockets, `webpacker:compile` is automatically aliased to `assets:precompile`. Similar to sprockets both rake tasks will compile packs in production mode but will use `RAILS_ENV` to load configuration from `config/webpacker.yml` (if available).
@@ -407,7 +399,7 @@ When compiling assets for production on a remote server, such as a continuous in
407
399
  - [Webpack-dev-server](./docs/webpack-dev-server.md)
408
400
  - [Environment Variables](./docs/env.md)
409
401
  - [Folder Structure](./docs/folder-structure.md)
410
- - [Assets](./docs/assets.md) - [CSS, Sass and SCSS](./docs/css.md) - [ES6](./docs/es6.md)
402
+ - [Assets](./docs/assets.md) - [CSS, Sass and SCSS](./docs/css.md) - [ES6](./docs/es6.md), [Target browsers](./docs/target.md)
411
403
  - [Props](./docs/props.md)
412
404
  - [Typescript](./docs/typescript.md)
413
405
  - [Yarn](./docs/yarn.md)
data/docs/css.md CHANGED
@@ -6,7 +6,7 @@ Webpacker supports importing CSS, Sass and SCSS files directly into your JavaScr
6
6
  Importing and loading styles is a two step process:
7
7
 
8
8
  1. You need to tell webpack which file(s) it has to compile and know how to load
9
-
9
+
10
10
  When you do `import '../scss/application.scss'`, you're telling webpack to include `application.scss` in the build. This does not mean it's going to be compiled into your javascript, only that webpack now compiles and knows how to load this file. (How that file compilation is handled is depending on how your loaders (`css-loader`, `sass-loader`, `file-loader`, etc.) are configured.)
11
11
 
12
12
  2. You need to load those files in your views
@@ -18,6 +18,51 @@ Importing and loading styles is a two step process:
18
18
 
19
19
  ## Import global styles into your JS app
20
20
 
21
+ ### Importing CSS as a multi-file pack (Webpacker v5)
22
+
23
+ When you add a CSS/SCSS/SASS file to `app/javascript/packs/` directory, make sure to use the same pack name as its complementary JavaScript pack, e.g. `application.js` and `application.css`. By Webpacker convention (as of Webpacker v5), this will bundle `application.js` and `application.scss` as part of the same entry point (also described as [a multi-file entry point in the webpack docs](https://webpack.js.org/concepts/entry-points/#single-entry-shorthand-syntax)). With this approach, you can avoid importing CSS from JS, if desired.
24
+
25
+ ```
26
+ app/
27
+ javascript/
28
+ packs/
29
+ application.js
30
+ application.scss
31
+ ```
32
+
33
+ ### Importing CSS from CSS
34
+
35
+ You can import additional CSS/SCSS/SASS files from within a CSS file:
36
+
37
+ ```
38
+ app/
39
+ javascript/
40
+ stylesheets/
41
+ application.scss
42
+ posts.scss
43
+ comments.scss
44
+ ```
45
+
46
+ ```css
47
+ /* app/javascript/stylesheets/application.scss */
48
+
49
+ @import './posts';
50
+ @import './comments';
51
+ ```
52
+
53
+ ### Importing CSS provided by an NPM package from SCSS/CSS
54
+
55
+ Given your application installs an NPM package that provides CSS, such as `flatpickr`, you can import the CSS file(s) by path from the package directory within `node_modules/`:
56
+
57
+ ```js
58
+ /* app/javascript/stylesheets/application.scss */
59
+
60
+ @import "flatpickr/dist/flatpickr.css"
61
+ ```
62
+
63
+
64
+ ### Importing CSS from JS
65
+
21
66
  ```sass
22
67
  // app/javascript/hello_react/styles/hello-react.sass
23
68
 
@@ -42,6 +87,16 @@ const Hello = props => (
42
87
  )
43
88
  ```
44
89
 
90
+ ### Importing CSS provided by an NPM package from JS
91
+
92
+ Given your application installs an NPM package that provides CSS, such as `flatpickr`, you can import the CSS file(s) by path from the package directory within `node_modules/`. This is an alternative to importing from within a CSS file, as above:
93
+
94
+ ```js
95
+ // app/javascript/packs/application.js
96
+
97
+ import "flatpickr/dist/flatpickr.css"
98
+ ```
99
+
45
100
  ## Import scoped styles into your JS app
46
101
 
47
102
  Stylesheets that end with `.module.*` are treated as [CSS Modules](https://github.com/css-modules/css-modules).
@@ -147,14 +202,14 @@ You can use Yarn to add bootstrap or any other modules available on npm:
147
202
  yarn add bootstrap
148
203
  ```
149
204
 
150
- Import Bootstrap and theme (optional) CSS in your app/javascript/packs/app.js file:
205
+ Import Bootstrap and theme (optional) CSS in your app/javascript/packs/application.js file:
151
206
 
152
207
  ```js
153
208
  import 'bootstrap/dist/css/bootstrap'
154
209
  import 'bootstrap/dist/css/bootstrap-theme'
155
210
  ```
156
211
 
157
- Or in your app/javascript/app.sass file:
212
+ Or in your app/javascript/packs/application.sass file:
158
213
 
159
214
  ```sass
160
215
  // ~ to tell that this is not a relative import
data/docs/integrations.md CHANGED
@@ -91,7 +91,7 @@ You can read more about this in the [Vue docs](https://vuejs.org/v2/guide/instal
91
91
 
92
92
  ### Lazy loading integration
93
93
 
94
- See [docs/es6](docs/es6.md) to know more about Webpack and Webpacker configuration.
94
+ See [docs/es6](es6.md) to know more about Webpack and Webpacker configuration.
95
95
 
96
96
  For instance, you can lazy load Vue JS components:
97
97
 
data/docs/target.md ADDED
@@ -0,0 +1,22 @@
1
+ # Target browsers
2
+
3
+ By default webpacker provides these front-end tools:
4
+ - [@babel/preset-env](https://github.com/babel/babel/tree/master/packages/babel-preset-env)
5
+ - [Autoprefixer](https://github.com/postcss/autoprefixer)
6
+ - [postcss-preset-env](https://github.com/csstools/postcss-preset-env)
7
+
8
+ All these tools use [Browserslist](https://github.com/browserslist/browserslist) to detect which environment your users have
9
+
10
+ Webpacker browserslist default target:
11
+ ```
12
+ defaults
13
+ ```
14
+
15
+ `defaults`: `(> 0.5%, last 2 versions, Firefox ESR, not dead)`, [browserl.ist](https://browserl.ist/) is an online tool to check what browsers will be selected by some query.
16
+
17
+ To keep browsers data up to date, you need to run:
18
+ ```bash
19
+ yarn upgrade caniuse-lite
20
+ ```
21
+
22
+ at least once every few months, to prevent such [problems](https://github.com/browserslist/browserslist/issues/492)
data/docs/testing.md CHANGED
@@ -32,7 +32,7 @@ It is beneficial to use the same webpack configuration file (generated by webpac
32
32
  ```js
33
33
  // config/webpack/test.js
34
34
  const environment = require('./environment')
35
- environment.plugins.get('Manifest').opts.writeToFileEmit = process.env.NODE_ENV !== 'test'
35
+ environment.plugins.get('Manifest').options.writeToFileEmit = process.env.NODE_ENV !== 'test'
36
36
  environment.loaders.append('istanbul-instrumenter', {
37
37
  test: /\.ts$/,
38
38
  enforce: "post",
@@ -4,11 +4,13 @@
4
4
 
5
5
  1. Read the error message carefully. The error message will tell you the precise key value
6
6
  that is not matching what Webpack expects.
7
- 2. Put a `debugger` statement in your Webpack configuration and run `bin/webpack --debug`.
7
+ 2. Put a `debugger` statement in your Webpack configuration and run `bin/webpack --debug-webpacker`.
8
8
  If you have a node debugger installed, you'll see the Chrome debugger for your webpack
9
9
  config. For example, install the Chrome extension [NiM](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj) and
10
10
  set the option for the dev tools to open automatically. For more details on debugging,
11
11
  see the official [Webpack docs on debugging](https://webpack.js.org/contribute/debugging/#devtools)
12
+ 3. Any arguments that you add to bin/webpack get sent to webpack. For example, you can pass `--debug` to switch loaders to debug mode. See [webpack CLI debug options](https://webpack.js.org/api/cli/#debug-options) for more information on the available options.
13
+ 4. You can also pass additional options to the command to run the webpack-dev-server and start the webpack-dev-server with the option `--debug-webpacker`
12
14
 
13
15
  ## ENOENT: no such file or directory - node-sass
14
16
 
data/docs/typescript.md CHANGED
@@ -1,18 +1,98 @@
1
- # Typescript
1
+ # TypeScript
2
2
 
3
+ ## Installation
3
4
 
4
- ## Typescript with React
5
+ 1. Run the TypeScript installer
5
6
 
6
- 1. Setup react using Webpacker [react installer](../README.md#react). Then run the typescript installer
7
+ ```bash
8
+ bundle exec rails webpacker:install:typescript
9
+ ```
10
+
11
+ After that, a new file called `hello_typescript.ts` will be present in your `packs` directory (or rather the `source_entry_path` of your `webpacker.yml` configuration). You're now ready to write TypeScript.
12
+
13
+ ## (Optional) Adding Compile-Time Type Checking
14
+
15
+ The default installation only transpiles your TypeScript code using Babel. If you would like to enable type checking as part of the Webpack compilation process (i.e. fail the build if there are TS errors), you can do the following:
16
+
17
+ 1. Install the Fork TS Checker Webpack Plugin
18
+
19
+ ```sh
20
+ yarn add --dev fork-ts-checker-webpack-plugin
21
+ ```
22
+
23
+ 2. Then add it to your development environment config in `config/webpack/development.js`
24
+
25
+ ```js
26
+ const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
27
+ const path = require("path");
28
+
29
+ environment.plugins.append(
30
+ "ForkTsCheckerWebpackPlugin",
31
+ new ForkTsCheckerWebpackPlugin({
32
+ typescript: {
33
+ configFile: path.resolve(__dirname, "../../tsconfig.json"),
34
+ },
35
+ async: false,
36
+ })
37
+ );
38
+ ```
39
+
40
+ If you are `fork-ts-checker-webpack-plugin` older than 5.0, the `tsconfig` option also needs to be specified:
41
+
42
+ ```js
43
+ const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
44
+ const path = require("path");
45
+
46
+ environment.plugins.append(
47
+ "ForkTsCheckerWebpackPlugin",
48
+ new ForkTsCheckerWebpackPlugin({
49
+ // this is a relative path to your project's TypeScript config
50
+ tsconfig: path.resolve(__dirname, "../../tsconfig.json"),
51
+ // non-async so type checking will block compilation
52
+ async: false,
53
+ })
54
+ );
55
+ ```
56
+
57
+ ## Upgrading to 5.1
58
+
59
+ If you update your App to `webpacker >= 5.1` and had TypeScript installed before, you need to add some new/remove some old configurations:
60
+
61
+ 1. Remove old packages:
62
+ - `yarn remove ts-loader`
63
+
64
+ 2. Add new packages:
65
+ - `yarn add @babel/preset-typescript`
66
+
67
+ 3. Remove old configuration files:
68
+ - Delete this file: `config/webpack/loaders/typescript.js`
69
+
70
+ 4. Remove the following lines from `config/webpack/environment.js`:
71
+ - `const typescript = require('./loaders/typescript')`
72
+ - `environment.loaders.prepend('typescript', typescript)`
73
+
74
+ 5. Add the TypeScript preset to your `babel.config.js`:
75
+ - This line `['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]` has to be added as the last item to the `presets` array in your `babel.config.js`
76
+
77
+ ### Upgrading to 5.1 for Vue users
78
+
79
+ 1. Remove old packages:
80
+ - `yarn remove ts-loader pnp-webpack-plugin`
81
+
82
+ 2. Follow point 3 and 4 from the `TypeScript with Vue components` section
83
+
84
+ ## TypeScript with React
85
+
86
+ 1. Setup react using Webpacker [react installer](../README.md#react). Then run the TypeScript installer
7
87
 
8
88
  ```bash
9
89
  bundle exec rails webpacker:install:typescript
10
90
  ```
11
91
 
12
- 2. Rename the generated `hello_react.js` to `hello_react.tsx`. Make the file valid typescript and
13
- now you can use typescript, JSX with React.
92
+ 2. Rename the generated `hello_react.js` to `hello_react.tsx`. Make the file valid TypeScript and
93
+ now you can use TypeScript, JSX with React.
14
94
 
15
- ## Typescript with Vue components
95
+ ## TypeScript with Vue components
16
96
 
17
97
  1. Setup Vue using the Webpacker [Vue installer](../README.md#vue). Then run the TypeScript installer
18
98
 
@@ -21,7 +101,8 @@ bundle exec rails webpacker:install:typescript
21
101
  ```
22
102
 
23
103
  2. Rename generated `hello_vue.js` to `hello_vue.ts`.
24
- 3. Change the generated `babel.config.js` from
104
+ 3. Install the right Babel preset: `yarn add babel-preset-typescript-vue`
105
+ 4. Change the generated `babel.config.js` from
25
106
 
26
107
  ```js
27
108
  ["@babel/preset-typescript", { "allExtensions": true, "isTSX": true }]
@@ -35,7 +116,7 @@ to
35
116
 
36
117
  and now you can use `<script lang="ts">` in your `.vue` component files. See [the babel-preset-typescript-vue docs](https://www.npmjs.com/package/babel-preset-typescript-vue) for more info.
37
118
 
38
- ## HTML templates with Typescript and Angular
119
+ ## HTML templates with TypeScript and Angular
39
120
 
40
121
  After you have installed Angular using `bundle exec rails webpacker:install:angular`
41
122
  you would need to follow these steps to add HTML templates support:
@@ -19,7 +19,7 @@ Now if you refresh your Rails view everything should work as expected.
19
19
  Webpacker out-of-the-box supports HMR with `webpack-dev-server` and
20
20
  you can toggle it by setting `dev_server/hmr` option inside `webpacker.yml`.
21
21
 
22
- Checkout this guide for more information:
22
+ Check out this guide for more information:
23
23
 
24
24
  - https://webpack.js.org/configuration/dev-server/#devserver-hot
25
25
 
@@ -56,9 +56,7 @@ module.exports = function(api) {
56
56
  [
57
57
  '@babel/plugin-transform-runtime',
58
58
  {
59
- helpers: false,
60
- regenerator: true,
61
- corejs: false
59
+ helpers: false
62
60
  }
63
61
  ],
64
62
  [
@@ -10,7 +10,7 @@ default: &default
10
10
 
11
11
  # Additional paths webpack should lookup modules
12
12
  # ['app/assets', 'engine/foo/app/assets']
13
- resolved_paths: []
13
+ additional_paths: []
14
14
 
15
15
  # Reload manifest.json on all requests so we reload latest compiled packs
16
16
  cache_manifest: false
@@ -34,7 +34,7 @@ if File.exists?(".gitignore")
34
34
  end
35
35
  end
36
36
 
37
- if Webpacker::VERSION =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
37
+ if Webpacker::VERSION.match?(/^[0-9]+\.[0-9]+\.[0-9]+$/)
38
38
  say "Installing all JavaScript dependencies [#{Webpacker::VERSION}]"
39
39
  run "yarn add @rails/webpacker@#{Webpacker::VERSION}"
40
40
  else
@@ -42,6 +42,14 @@ else
42
42
  run "yarn add @rails/webpacker@next"
43
43
  end
44
44
 
45
+ package_json = File.read("#{__dir__}/../../package.json")
46
+ webpack_version = package_json.match(/"webpack": "(.*)"/)[1]
47
+ webpack_cli_version = package_json.match(/"webpack-cli": "(.*)"/)[1]
48
+
49
+ # needed for experimental Yarn 2 support and should not harm Yarn 1
50
+ say "Installing webpack and webpack-cli as direct dependencies"
51
+ run "yarn add webpack@#{webpack_version} webpack-cli@#{webpack_cli_version}"
52
+
45
53
  say "Installing dev server for live reloading"
46
54
  run "yarn add --dev webpack-dev-server"
47
55
 
@@ -9,7 +9,7 @@ if File.exist?(package_json)
9
9
  package = JSON.parse(File.read(package_json))
10
10
  package["dependencies"] ||= {}
11
11
 
12
- if package["dependencies"].keys.include?("react")
12
+ if package["dependencies"].key?("react")
13
13
  additional_packages = "@types/react @types/react-dom"
14
14
  example_source = "react"
15
15
  end
@@ -34,9 +34,6 @@ copy_file "#{__dir__}/examples/typescript/hello_typescript.ts",
34
34
  "#{Webpacker.config.source_entry_path}/hello_typescript.ts"
35
35
 
36
36
  say "Installing all typescript dependencies"
37
- run "yarn add typescript #{additional_packages}"
38
-
39
- say "Installing all typescript dev-dependencies"
40
- run "yarn add @babel/preset-typescript babel-preset-typescript-vue -D"
37
+ run "yarn add typescript @babel/preset-typescript #{additional_packages}"
41
38
 
42
39
  say "Webpacker now supports typescript 🎉", :green
@@ -3,7 +3,7 @@ namespace :webpacker do
3
3
  desc "Verifies if Node.js is installed"
4
4
  task :check_node do
5
5
  begin
6
- node_version = `node -v || nodejs -v`
6
+ node_version = `node -v || nodejs -v`.strip
7
7
  raise Errno::ENOENT if node_version.blank?
8
8
 
9
9
  pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath