Created
June 10, 2017 10:59
-
-
Save Lxxyx/cb4bf292c7880092acddb291919e5bf0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const fs = require('fs') | |
const path = require('path') | |
const { | |
exec | |
} = require('child_process') | |
const file = process.argv[2] | |
const filename = file.split('.')[0] | |
if (!file) { | |
throw new Error('require file') | |
} | |
const content = fs.readFileSync(path.resolve(__dirname, file), 'utf-8') | |
let result = '' | |
content.split('\n').forEach((command, index) => { | |
if (command === '') return | |
if (index === 0) { | |
command += ' \\ \n' | |
} else { | |
command = '&& ' + command + ' \\ \n' | |
} | |
result += command | |
}) | |
fs.writeFileSync(path.resolve(__dirname, filename + '.sh'), result, { | |
encoding: 'utf-8' | |
}) | |
exec('open .') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment