-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from platanus/node-version-check
Node version check
- Loading branch information
Showing
6 changed files
with
83 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Potassium | ||
class NodeVersionEnsurer | ||
def ensure! | ||
raise VersionError.new(install_message) if installed_node_version.nil? | ||
raise VersionError.new(update_message) if Potassium::NODE_VERSION != installed_node_version | ||
end | ||
|
||
private | ||
|
||
def installed_node_version | ||
node_version = `node -v 2>&1` | ||
return node_version.delete('^[0-9\.]').split('.').first if $?.success? | ||
end | ||
|
||
def install_message | ||
<<~HERE | ||
Node doesn't appear to be installed. | ||
Please make sure you have node #{Potassium::NODE_VERSION} installed. | ||
HERE | ||
end | ||
|
||
def update_message | ||
<<~HERE | ||
An unsupported version of node was found. | ||
Please make sure you have node #{Potassium::NODE_VERSION} installed. Newer versions may work but potassium only supports that one. | ||
If you really need to run potassium with a different version of node, re-run this command with the `--no-node-version-check` flag. | ||
HERE | ||
end | ||
end | ||
end |