1 | #!/usr/bin/env node
|
2 | const fs = require('fs')
|
3 | const path = require('path')
|
4 | const colors = require('./colors')
|
5 | const execSync = require('child_process').execSync
|
6 | const HOME = require('os').homedir()
|
7 | const PROFILE_PATH = HOME + path.sep + '.bash_profile'
|
8 |
|
9 | let SOURCE_COMMAND = '\n source ' + __dirname + path.sep + 'index.sh'
|
10 |
|
11 | let bashProfileContent = fs.readFileSync(PROFILE_PATH, 'utf8').toString()
|
12 | if (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 | }
|