Last active
April 16, 2018 14:28
-
-
Save meodai/81300122d5799668477ec0f44984d269 to your computer and use it in GitHub Desktop.
use NPM with no terminal
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
#!/usr/bin/env bash | |
# logging | |
function e_header() { echo -e "\n\033[1m$@\033[0m"; } | |
# install homebrew if not already there | |
if [[ ! "$(type -P brew)" ]]; then | |
e_header '🍳 Installing homebrew' | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
fi | |
# mupdate homebrew | |
e_header '🍳 Updating homebrew' | |
brew update | |
# installs n (js) if not already installed | |
if [[ ! "$(type -P n)" ]]; then | |
e_header '📚 Installing n' | |
sudo mkdir $(/usr/local/n) | |
sudo chown -R $(/usr/local/n) | |
brew install n | |
fi | |
# makes sure you own your npm folders | |
if [[ "$(stat -c '%U' $(npm config get prefix)/lib)" != "$(whoami)" ]]; then | |
e_header '❗ You should own your on node folder' | |
e_header '❗ Enter your OSX System password' | |
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} | |
fi | |
n "$(< .nvmrc)" | |
# makes sure git is installed | |
if [[ ! "$(type -P git)" ]]; then | |
e_header '📦 Installing GIT' | |
brew install git | |
brew install git-lfs | |
fi | |
npm install | |
e_header '🌊 hit (ctrl+c) to stop' | |
# you might what to change this, depends if you npm start task opens a browser or not | |
open 'http://localhost:9100/' | |
npm start |
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
// open this in the OSX Script Editor and do File > Export.. | |
// In the next dialog choose .app in "File Formormat" and save it at your project root alog with setup .setup-osx.sh | |
app = Application.currentApplication(); | |
app.includeStandardAdditions = true; | |
Terminal = Application('Terminal'); | |
Terminal.activate(); | |
targetWindow = Terminal.windows.at(0); | |
currentTab = targetWindow.selectedTab(); | |
// go to current folder | |
appPath = app.pathTo(this); | |
appFolder = (appPath + '').split('/'); | |
appFolder.pop(); | |
Terminal.doScript(`cd ${appFolder.join('/')}`, {in: currentTab}); | |
Terminal.doScript(`. .setup-osx.sh`, {in: currentTab}); | |
//Terminal.end() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment