Class: Lively::Electron::Packager::Npm

Inherits:
Generic
  • Object
show all
Defined in:
lib/lively/electron/packager/npm.rb

Overview

An npm (‘package-lock.json`) project layout with the corresponding `npm` command line.

Constant Summary

Constants inherited from Generic

Generic::ELECTRON_VERSION_RANGE

Instance Attribute Summary

Attributes inherited from Generic

#Semver range for the `electron` dependency written by {setup!}.

Instance Method Summary collapse

Methods inherited from Generic

#electron_executable_path, #install_hint, #run_install_in!

Instance Method Details

#install_commandObject



20
21
22
# File 'lib/lively/electron/packager/npm.rb', line 20

def install_command
	%w[npm install]
end

#setup!(package_root) ⇒ Object

Creates a ‘package.json` and installs Generic::ELECTRON_VERSION_RANGE when no manifest exists yet; see Generic#setup!.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/lively/electron/packager/npm.rb', line 27

def setup!(package_root)
	manifest = File.join(File.expand_path(package_root), "package.json")
	return if File.file?(manifest)
	
	run_subprocess!(%w[npm init -y], package_root, "npm init -y")
	run_subprocess!(
		[
			"npm", "install", "--save-prod",
			"electron@#{ELECTRON_VERSION_RANGE}"
		],
		package_root,
		"npm install electron"
	)
end

#to_sObject



17
# File 'lib/lively/electron/packager/npm.rb', line 17

def to_s = "npm"