Skip to content

Commit

Permalink
Move compilation lock file into the working directory (shakacode#272)
Browse files Browse the repository at this point in the history
* Move compilation lock file into the root path tmp directory

* Satisfy Rubocop

* Account for tmp path not being available
  • Loading branch information
tomdracz authored Apr 5, 2023
1 parent 2841d43 commit 80d784a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ _Please add entries here for your pull requests that are not yet released._

`@babel/preset-typescript` has been initialised in default configuration with `{ allExtensions: true, isTSX: true }` - meaning every file in the codebase was treated as TSX leading to potential issues. This has been removed and returns to sensible default of the preset which is to figure out the file type from the extensions. This change might affect generated output however so it is marked as breaking.

### Improved
- Move compilation lock file into the working directory. [PR 272](https://github.com/shakacode/shakapacker/pull/272) by [tomdracz](https://github.com/tomdracz).

## [v6.6.0] - March 7, 2023
### Improved
- Allow configuration of webpacker.yml through env variable. [PR 254](https://github.com/shakacode/shakapacker/pull/254) by [alecslupu](https://github.com/alecslupu).
Expand Down
15 changes: 13 additions & 2 deletions lib/webpacker/compiler.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "open3"
require "webpacker/compiler_strategy"
require "fileutils"

class Webpacker::Compiler
# Additional environment variables that the compiler is being run with
Expand Down Expand Up @@ -55,12 +56,22 @@ def wait_for_compilation_to_complete
end

def open_lock_file
lock_file_name = File.join(Dir.tmpdir, "shakapacker.lock")
File.open(lock_file_name, File::CREAT) do |lf|
create_lock_file_dir unless File.exist?(lock_file_path)

File.open(lock_file_path, File::CREAT) do |lf|
return yield lf
end
end

def create_lock_file_dir
dirname = File.dirname(lock_file_path)
FileUtils.mkdir_p(dirname)
end

def lock_file_path
config.root_path.join("tmp/shakapacker.lock")
end

def optionalRubyRunner
bin_webpack_path = config.root_path.join("bin/webpacker")
first_line = File.readlines(bin_webpack_path).first.chomp
Expand Down

0 comments on commit 80d784a

Please sign in to comment.