This file contains 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 message = (content: string, color: string) => { | |
const msg = emoji.emojify(content) | |
if (colors[color]) { | |
return colors[color](msg) | |
} | |
return msg | |
} |
This file contains 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 createScriptExec = (script: string) => { | |
let instance = null | |
return async function execute() { | |
if (instance) { | |
await kill(instance, 'SIGKILL') | |
} | |
instance = spawn(script, [], { shell: true }) |
This file contains 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
fromEvent(chokidar.watch(process.cwd()), 'all').pipe( | |
debounceTime(delay || 1000), | |
// ... | |
) |
This file contains 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 isInDirectory = (directories: string[]) => (filePath: string) => | |
directories.some(filePath.startsWith.bind(filePath)) | |
const isExpectedExtension = (extensions: string[]) => (extension: string) => | |
extensions.some(is(extension)) | |
// ... | |
const shouldPathBeIgnored = isInDirectory(ignoredDirectories) | |
const shouldPathBeWatched = isInDirectory(watchedDirectories) |
This file contains 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
fromEvent(chokidar.watch(process.cwd()), 'all').pipe( | |
// ... | |
map(([event, filePath]: string[]) => { | |
const filename = path.basename(filePath) | |
const extension = path.extname(filename) | |
return { | |
event, | |
filename, | |
extension, |
This file contains 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
fromEvent(chokidar.watch(process.cwd()), 'all').pipe( | |
// ... | |
) |
This file contains 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 parseArguments = (execution: program.Command) => { | |
const { ext = [], watch = [], ignore = [], delay = 0, exe } = execution | |
if (!exe) { | |
throw new Error('No script provided') | |
} | |
return { | |
delay, | |
extensions: ext.map((e) => `.${e}`), |
This file contains 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 parsers = { | |
int: (number: string) => parseInt(number, 10), | |
float: (number: string) => parseFloat(number), | |
list: (val: string) => val.split(','), | |
collect: (val, memo) => { | |
memo.push(val) | |
return memo | |
}, | |
} |
This file contains 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 commandArguments = program | |
.version('1.0.0') | |
.option('-e, --ext <items>', 'Extensions to watch', parsers.list) | |
.option('-w, --watch <items>', 'Directories to watch', parsers.list) | |
.option('-i, --ignore <items>', 'Directories to ignore', parsers.list) | |
.option('-d, --delay <n>', 'Delay before the execution', parsers.int) | |
.option('-x, --exe <script>', 'Execute script on restart') | |
.parse(process.argv) |
This file contains 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
interface Config { | |
transports?: Transport[]; | |
level?: Level; | |
} | |
const defaultConfig: Config = { | |
transports: [new transports.console({ level: 'info' })], | |
level: 'info', | |
}; |
NewerOlder