Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ascarter/dotfiles
base: c25f108821
...
head fork: ascarter/dotfiles
compare: 89ad924555
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 21, 2014
@ascarter Update node install
* Update to version v0.10.29
* Improve npm install and node uninstall
* Add node:list task
* Fix zsh checks for npm, bower, grunt for installing completion
2d0b176
@ascarter Add vim commands for go 89ad924
Showing with 49 additions and 19 deletions.
  1. +22 −11 rakelib/node.rake
  2. +21 −5 rakelib/utils.rb
  3. +3 −0  src/vimrc
  4. +3 −3 src/zshrc
View
33 rakelib/node.rake
@@ -7,7 +7,7 @@ namespace "node" do
# Install node.js from package
unless File.exist?('/usr/local/bin/node')
# TODO: Get list of releases and prompt user to pick
- release = 'v0.10.26'
+ release = 'v0.10.29'
pkg = "node-#{release}.pkg"
pkg_url = "http://nodejs.org/dist/#{release}/#{pkg}"
pkg_download(pkg_url) do |p|
@@ -15,27 +15,38 @@ namespace "node" do
end
end
end
- puts "Node.js: #{%x{/usr/local/bin/node --version}}"
- puts "npm: #{%x{/usr/local/bin/npm --version}}"
- # Update npm
- npm_update
+ node_version
# Install npm packages
pkgs = %w{bower coffeelint grunt-cli jslint jsonlint}
pkgs.each { |pkg| npm_install(pkg) }
-
- npm_list
end
-
+ desc "List installed modules"
+ task :list do
+ node_version
+ npm_ls
+ end
desc "Uninstall node"
task :uninstall do
if RUBY_PLATFORM =~ /darwin/
- pkg_uninstall("org.nodejs")
- ["/usr/local/lib/node", "/usr/local/lib/node_modules"].each do |dir|
- sudo_remove_dir(dir)
+ if File.exist?('/usr/local/bin/node')
+ # Remove all installed node modules and npm
+ npm_list.each do |pkg|
+ npm_uninstall pkg
+ end
+
+ npm_uninstall "npm"
+
+ pkg_uninstall("org.nodejs")
+
+ ["/usr/local/lib/node", "/usr/local/lib/node_modules"].each do |dir|
+ sudo_remove_dir(dir)
+ end
+ else
+ puts 'Node.js is not installed'
end
end
end
View
26 rakelib/utils.rb
@@ -237,11 +237,16 @@ def pkg_uninstall(pkg, prefix='/usr/local')
# npm
#
+def node_version
+ puts "Node.js: #{%x{/usr/local/bin/node --version}}"
+ puts "npm: #{%x{/usr/local/bin/npm --version}}"
+end
+
def npm_install(pkg)
- if %x{npm list --global --parseable #{pkg}}
- puts "#{pkg} already installed"
- else
+ if %x{npm list --global --parseable #{pkg}}.strip().empty?
sudo "npm install --global #{pkg}"
+ else
+ puts "#{pkg} already installed"
end
end
@@ -253,10 +258,21 @@ def npm_uninstall(pkg)
sudo "npm uninstall --global #{pkg}"
end
-def npm_list(pkg="", depth=0)
- sudo "npm list --global --depth=#{depth} #{pkg}"
+def npm_list
+ packages = []
+ %x{npm list --global --parseable --depth=0}.split("\n").each do |pkg|
+ pkg_name = File.basename(pkg)
+ unless %w{lib npm}.include?(pkg_name)
+ packages.push(File.basename(pkg_name))
+ end
+ end
+ return packages
end
+def npm_ls
+ puts "Installed npm modules:"
+ npm_list.each { |pkg| puts " #{pkg}" }
+end
#
# Mac OS X defaults
View
3  src/vimrc
@@ -93,6 +93,9 @@ autocmd FileType go compiler go
autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent
autocmd BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
+autocmd FileType go autocmd BufWritePre <buffer> Fmt
+autocmd FileType go compiler go
+
" Don't create extra files
"set nobackup
"set nowritebackup
View
6 src/zshrc
@@ -22,17 +22,17 @@ if [[ -d $GOROOT && -e $GOROOT/misc/zsh/go ]]; then
fi
# npm
-if [ -n "`which npm`" ]; then
+if which npm &>/dev/null; then
. <(npm completion)
fi
# bower
-if [ -n "`which npm`" ]; then
+if which bower &>/dev/null; then
. <(bower completion)
fi
# grunt
-if [ -n "`which grunt`" ]; then
+if which grunt &>/dev/null; then
. <(grunt --completion=zsh)
fi

No commit comments for this range

Something went wrong with that request. Please try again.