UNPKG

794 BJavaScriptView Raw
1#!/usr/bin/env node
2const fs = require('fs')
3const path = require('path')
4const colors = require('./colors')
5const execSync = require('child_process').execSync
6const HOME = require('os').homedir()
7const PROFILE_PATH = HOME + path.sep + '.bash_profile'
8
9let SOURCE_COMMAND = '\n source ' + __dirname + path.sep + 'index.sh'
10
11let bashProfileContent = fs.readFileSync(PROFILE_PATH, 'utf8').toString()
12if (bashProfileContent.indexOf(SOURCE_COMMAND) >= 0) {
13 let secondLine = SOURCE_COMMAND.split('\n')[1]
14 bashProfileContent = bashProfileContent.replace(SOURCE_COMMAND, '\n# ' + secondLine)
15
16 fs.writeFileSync(PROFILE_PATH, bashProfileContent, 'utf8')
17} else {
18 console.log('> It was not found in your ~/.bash_profile\nPerhaps you moved it, importing it from some different file?')
19}