-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.mjs
executable file
·35 lines (26 loc) · 1.08 KB
/
cli.mjs
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
#! /usr/bin/env node
import fs from 'fs'
import sade from 'sade'
import { grokFile, buildCss, buildJs } from './index.mjs'
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'))
const prog = sade('chefs-kiss <src> <dest>', true)
prog
.version(pkg.version)
// .option('-c, --config', 'Provide path to custom config', 'spaghetti.config.js')
.option('-f, --format', 'Format: iife, cjs, esm', 'iife')
.option('-g, --global', 'Specify a global name e.g. window[name]', undefined)
.option('-m, --minify', 'Minify', true)
.option('-s, --sourcemap', 'Output a sourcemap', true)
.option('-l, --legacy', 'Support legacy browsers', false)
prog
.example('src/index.js build/index.js')
.example('app/style.css public/style.css')
.action(async (src, dest, opts) => {
console.log(`\n spaghetti v${pkg.version}`)
src = grokFile(src)
dest = grokFile(dest)
const then = Date.now()
await (src.extname === '.css' ? buildCss(src, dest, opts) : buildJs(src, dest, opts))
console.log(`\n made spaghetti in ${Date.now() - then}ms\n`)
})
prog.parse(process.argv)