8
8
9
9
Bundler ::GemHelper . install_tasks
10
10
11
+ require "package_json"
12
+
11
13
def copy_react_asset ( webpack_file , destination_file )
12
14
full_webpack_path = File . expand_path ( "../react-builds/build/#{ webpack_file } " , __FILE__ )
13
15
full_destination_path = File . expand_path ( "../lib/assets/react-source/#{ destination_file } " , __FILE__ )
14
16
FileUtils . cp ( full_webpack_path , full_destination_path )
15
17
end
16
18
17
- # Move to `dirname` and execute `yarn {cmd}`
18
- def yarn_run_in ( dirname , cmd )
19
- Dir . chdir ( dirname ) do
20
- `yarn #{ cmd } `
21
- end
22
- end
23
-
24
19
namespace :react do
25
20
desc "Run the JS build process to put files in the gem source"
26
21
task update : %i[ install build copy ]
27
22
28
23
desc "Install the JavaScript dependencies"
29
24
task :install do
30
- yarn_run_in ( "react-builds" , "install" )
25
+ PackageJson . read ( "react-builds" ) . manager . install
31
26
end
32
27
33
28
desc "Build the JS bundles with Webpack"
34
29
task :build do
35
- yarn_run_in ( "react-builds" , "build" )
30
+ PackageJson . read ( "react-builds" ) . manager . run ( "build" )
36
31
end
37
32
38
33
desc "Copy browser-ready JS files to the gem's asset paths"
@@ -51,12 +46,12 @@ namespace :ujs do
51
46
52
47
desc "Install the JavaScript dependencies"
53
48
task :install do
54
- `yarn install`
49
+ PackageJson . read . manager . install
55
50
end
56
51
57
52
desc "Build the JS bundles with Webpack"
58
53
task :build do
59
- `yarn build`
54
+ PackageJson . read . manager . run ( " build" )
60
55
end
61
56
62
57
desc "Copy browser-ready JS files to the gem's asset paths"
@@ -87,7 +82,7 @@ task default: :test
87
82
88
83
task :test_setup do
89
84
Dir . chdir ( "./test/dummy" ) do
90
- `yarn install`
85
+ PackageJson . read . manager . install
91
86
end
92
87
end
93
88
0 commit comments