forked from lumeland/lume
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
39 lines (33 loc) · 935 Bytes
/
init.js
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
import { parse } from "../deps/flags.js";
import { brightGreen } from "../deps/colors.js";
import { version } from "../cli.js";
import { validateArgsCount } from "./utils.js";
export const HELP = `
${brightGreen("lume init")}: create a config file for a new site
USAGE:
lume init [OPTIONS]
OPTIONS:
--config <file> specify the lume config file. Default: _config.js
`;
export async function run(args) {
const options = parse(args, {
string: ["config"],
unknown(option) {
if (option.startsWith("-")) {
throw new Error(`Unknown option: ${option}`);
}
},
default: {
config: "_config.js",
},
});
validateArgsCount("init", options._, 1);
await Deno.writeTextFile(
options.config,
`import lume from "https://deno.land/x/lume@${version}/mod.js";
const site = lume();
export default site;
`,
);
console.log(brightGreen("Created config file"), options.config);
}