Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add argument for output directory #32

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions bin/auto-reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { Command } from 'commander';
import { build, createServer } from 'vite';
import { ViteEjsPlugin as viteEjsPlugin } from 'vite-plugin-ejs';
import { getTheme, getTitle } from '../lib/utils.js';

const __dirname = fileURLToPath(new URL('.', import.meta.url));
const argv = process.argv.slice(2);
const cwd = process.cwd();

const themeFolder = path.dirname(getTheme());
Expand Down Expand Up @@ -47,8 +47,33 @@ async function start() {
server.bindCLIShortcuts({ print: true });
}

if (!argv[0] || argv[0] === 'start') {
start();
} else if (argv[0] === 'build') {
build(config);
}
const program = new Command();

program.name(process.env.npm_package_name);
program.description(process.env.npm_package_description);
program.version(process.env.npm_package_version);

program
.command('start', {
isDefault: true,
})
.description('Live-reloading server for your slides.')
.action(start);

program
.command('build')
.description('Build a static copy of your presentation.')
.option('-o, --outDir <path>', 'Output directory', config.build.outDir)
.action((options) =>
build({
...config,
build: {
...config.build,
outDir: options.outDir
? path.resolve(cwd, options.outDir)
: config.build.outDir,
},
}),
);

program.parse();
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "auto-reveal",
"version": "0.2.1",
"description": "",
"keywords": [],
"description": "The command-line interface for reveal.js presentations.",
"keywords": ["reveal.js", "cli", "markdown"],
"repository": {
"type": "git",
"url": "[email protected]:mainmatter/auto-reveal.git"
Expand All @@ -15,11 +15,12 @@
"auto-reveal": "./bin/auto-reveal.js"
},
"scripts": {
"format": "biome check --apply .",
"format": "biome check --write .",
"lint": "biome check .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"commander": "^12.1.0",
"reveal.js": "5.1.0",
"vite": "5.4.0",
"vite-plugin-ejs": "1.7.0",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.