-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbashrc-pack
More file actions
executable file
·47 lines (36 loc) · 1.19 KB
/
bashrc-pack
File metadata and controls
executable file
·47 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
// Attach scripts to the bashrc skeleton
const LogDwim = require(`@nilsboy/log-dwim`)
const logger = new LogDwim()
const { TRACE, DEBUG, INFO, WARN, ERROR, DIE, DUMP } = logger
const path = require(`path`)
const fs = require(`fs-extra`)
const glob = require(`glob`).sync
const _ = require(`lodash`)
const wd = path.join(process.env.HOME, `src`, `bin`)
process.chdir(wd)
let bashrc = fs.readFileSync("../dotfiles/bashrc").toString()
let bashrcFileName = path.resolve("../bashrc/bashrc")
let appsCount = 0
let filesToSkip = [
`README`,
`package-lock.json`,
]
INFO(`Packing bin...`)
for (const binFileName of glob(path.join(wd, '*'))) {
if(fs.lstatSync(binFileName).isDirectory()) {
continue
}
if(filesToSkip.includes(path.basename(binFileName))) {
continue
}
DEBUG(`binFileName:`, binFileName)
const bin = fs.readFileSync(binFileName).toString()
let description = `fatpacked app ${path.basename(binFileName)}`
bashrc += _.padEnd("### " + description + " ", 80, `#`) + "\n\n"
bashrc += bin + "\n"
appsCount++;
}
bashrc += _.padEnd("### fatpacked apps END ", 80, "#") + "\n\n"
fs.writeFileSync(bashrcFileName, bashrc)
INFO(`Done - apps packed: ${appsCount}`)