mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
30 lines
690 B
JavaScript
30 lines
690 B
JavaScript
import path from 'path'
|
|
import sander from 'sander'
|
|
|
|
function parse () {
|
|
const BOOSTNOTERC = '.boostnoterc'
|
|
const homePath = global.process.env.HOME || global.process.env.USERPROFILE
|
|
const boostnotercPath = path.join(homePath, BOOSTNOTERC)
|
|
|
|
if (!sander.existsSync(boostnotercPath)) return {}
|
|
return JSON.parse(sander.readFileSync(boostnotercPath).toString())
|
|
}
|
|
|
|
function exec (boostnotercPath) {
|
|
const config = this.parse(boostnotercPath)
|
|
if (config.execs === undefined) return
|
|
_.forEach(config.execs, (exec) => {
|
|
try {
|
|
eval(exec)
|
|
} catch (e) {
|
|
// Ignore any errors in ~/.boostnoterc
|
|
console.log(e)
|
|
}
|
|
})
|
|
}
|
|
|
|
export default {
|
|
parse,
|
|
exec
|
|
}
|