88
99Bundler ::GemHelper . install_tasks
1010
11+ require "package_json"
12+
1113def copy_react_asset ( webpack_file , destination_file )
1214 full_webpack_path = File . expand_path ( "../react-builds/build/#{ webpack_file } " , __FILE__ )
1315 full_destination_path = File . expand_path ( "../lib/assets/react-source/#{ destination_file } " , __FILE__ )
1416 FileUtils . cp ( full_webpack_path , full_destination_path )
1517end
1618
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-
2419namespace :react do
2520 desc "Run the JS build process to put files in the gem source"
2621 task update : %i[ install build copy ]
2722
2823 desc "Install the JavaScript dependencies"
2924 task :install do
30- yarn_run_in ( "react-builds" , "install" )
25+ PackageJson . read ( "react-builds" ) . manager . install
3126 end
3227
3328 desc "Build the JS bundles with Webpack"
3429 task :build do
35- yarn_run_in ( "react-builds" , "build" )
30+ PackageJson . read ( "react-builds" ) . manager . run ( "build" )
3631 end
3732
3833 desc "Copy browser-ready JS files to the gem's asset paths"
@@ -51,12 +46,12 @@ namespace :ujs do
5146
5247 desc "Install the JavaScript dependencies"
5348 task :install do
54- `yarn install`
49+ PackageJson . read . manager . install
5550 end
5651
5752 desc "Build the JS bundles with Webpack"
5853 task :build do
59- `yarn build`
54+ PackageJson . read . manager . run ( " build" )
6055 end
6156
6257 desc "Copy browser-ready JS files to the gem's asset paths"
@@ -87,7 +82,7 @@ task default: :test
8782
8883task :test_setup do
8984 Dir . chdir ( "./test/dummy" ) do
90- `yarn install`
85+ PackageJson . read . manager . install
9186 end
9287end
9388
0 commit comments