diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-02-15 23:18:21 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-02-16 08:46:29 +0300 |
commit | e65298794725e5df22d7e1fdfee62fbc49c44857 (patch) | |
tree | 37b21e15e8d3c54e68ef9164835bd0951fdffed6 /lib/tasks/yarn.rake | |
parent | b36542e1cbb90134435f5333c46dd0dc89bb468f (diff) |
ensure rake tasks produce helpful error messages for node dependency issues
Diffstat (limited to 'lib/tasks/yarn.rake')
-rw-r--r-- | lib/tasks/yarn.rake | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/tasks/yarn.rake b/lib/tasks/yarn.rake new file mode 100644 index 00000000000..351f6887f7b --- /dev/null +++ b/lib/tasks/yarn.rake @@ -0,0 +1,40 @@ + +namespace :yarn do + desc 'Ensure Yarn is installed' + task :available do + unless system('yarn --version', out: File::NULL) + warn( + 'Error: Yarn executable was not detected in the system.'.color(:red), + 'Download Yarn at https://yarnpkg.com/en/docs/install'.color(:green) + ) + abort + end + end + + desc 'Ensure Node dependencies are installed' + task check: ['yarn:available'] do + unless system('yarn check --ignore-engines', out: File::NULL) + warn( + 'Error: You have unmet dependencies. (`yarn check` command failed)'.color(:red), + 'Run `yarn install` to install missing modules.'.color(:green) + ) + abort + end + end + + desc 'Install Node dependencies with Yarn' + task install: ['yarn:available'] do + unless system('yarn install --force --pure-lockfile --ignore-engines') + abort 'Error: Unable to install node modules.'.color(:red) + end + end + + desc 'Remove Node dependencies' + task :clobber do + warn 'Purging ./node_modules directory'.color(:red) + FileUtils.rm_rf 'node_modules' + end +end + +desc 'Install Node dependencies with Yarn' +task yarn: ['yarn:install'] |