language/node: remove unneeded scripts prior to installation
This commit is contained in:
parent
cbb0b87e75
commit
c062429ddd
@ -16,6 +16,17 @@ module Language
|
|||||||
# fed to `npm install` only symlinks are created linking back to that
|
# fed to `npm install` only symlinks are created linking back to that
|
||||||
# directory, consequently breaking that assumption. We require a tarball
|
# directory, consequently breaking that assumption. We require a tarball
|
||||||
# because npm install creates a "real" installation when fed a tarball.
|
# because npm install creates a "real" installation when fed a tarball.
|
||||||
|
if (package = Pathname("package.json")) && package.exist?
|
||||||
|
begin
|
||||||
|
pkg_json = JSON.parse(package.read)
|
||||||
|
rescue JSON::ParserError
|
||||||
|
$stderr.puts "Could not parse package.json"
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
prepare_removed = pkg_json["scripts"]&.delete("prepare")
|
||||||
|
prepack_removed = pkg_json["scripts"]&.delete("prepack")
|
||||||
|
package.atomic_write(JSON.pretty_generate(pkg_json)) if prepare_removed || prepack_removed
|
||||||
|
end
|
||||||
output = Utils.popen_read("npm pack --ignore-scripts")
|
output = Utils.popen_read("npm pack --ignore-scripts")
|
||||||
raise "npm failed to pack #{Dir.pwd}" if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty?
|
raise "npm failed to pack #{Dir.pwd}" if !$CHILD_STATUS.exitstatus.zero? || output.lines.empty?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user