Skip to content

Commit

Permalink
Merge pull request #32 from mainmatter/pichfl/outdir
Browse files Browse the repository at this point in the history
Add argument for output directory
  • Loading branch information
pichfl authored Aug 9, 2024
2 parents 58bb6e4 + 0c465cb commit e07896a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
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.

0 comments on commit e07896a

Please sign in to comment.