Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 1bbee94

Browse files
committed
feat(cli): add basePath option
1 parent c95505f commit 1bbee94

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

packages/fusuma/src/cli/index.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,71 @@ async function cli() {
1111
prog
1212
.version(version)
1313
.description('CLI for easily make slides with Markdown')
14-
1514
.command('init', 'Create a configure file')
15+
.option('-b <directory>', 'A base path', prog.STRING, process.cwd())
1616
.option('-t [type]', 'Schema type', prog.STRING)
1717
.action((args, options, logger) => {
1818
resolve({
1919
type: 'init',
2020
options: {
21+
basePath: options.b,
2122
schema: options.t,
2223
},
2324
});
2425
})
2526

2627
.command('start', 'Start with webpack-dev-server')
28+
.option('-b <directory>', 'A base path', prog.STRING, process.cwd())
2729
.option('-i <directory>', 'A directory to load', prog.STRING, 'slides')
2830
.option('-p <port>', 'Dev server port', prog.INT, '8080')
2931
.action((args, options, logger) => {
3032
resolve({
3133
type: 'start',
3234
options: {
35+
basePath: options.b,
3336
inputDir: options.i,
3437
port: options.p,
3538
},
3639
});
3740
})
3841

3942
.command('build', 'Build with webpack')
43+
.option('-b <directory>', 'A base path', prog.STRING, process.cwd())
4044
.option('-i <directory>', 'A directory to load', prog.STRING, 'slides')
4145
.option('-o <directory>', 'A directory to output', prog.STRING, 'dist')
4246
.action((args, options, logger) => {
4347
resolve({
4448
type: 'build',
4549
options: {
50+
basePath: options.b,
4651
inputDir: options.i,
4752
outputDir: options.o,
4853
},
4954
});
5055
})
5156

5257
.command('deploy', 'Deploy to GitHub pages')
58+
.option('-b <directory>', 'A base path', prog.STRING, process.cwd())
5359
.option('-i <directory>', 'A directory to load', prog.STRING, 'dist')
5460
.action((args, options, logger) => {
5561
resolve({
5662
type: 'deploy',
57-
options: { outputDir: options.i },
63+
options: {
64+
basePath: options.b,
65+
outputDir: options.i
66+
},
5867
});
5968
})
6069

6170
.command('pdf', 'Export as PDF')
71+
.option('-b <directory>', 'A base path', prog.STRING, process.cwd())
6272
.option('-i <directory>', 'A directory to load', prog.STRING, 'dist')
6373
.option('-f <directory>', 'A filename of pdf', prog.STRING, 'slide.pdf')
6474
.action((args, options, logger) => {
6575
resolve({
6676
type: 'pdf',
6777
options: {
78+
basePath: options.b,
6879
inputDir: options.i,
6980
filename: options.f,
7081
},

packages/fusuma/src/tasks/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const deploy = require('./deploy');
99
const pdf = require('./pdf');
1010

1111
async function tasks({ type, options }) {
12-
const basePath = process.cwd();
13-
const inputDirPath = join(basePath, options.inputDir || 'slides');
14-
const outputDirPath = join(basePath, options.outputDir || 'dist');
12+
const { basePath, inputDir, outputDir } = options;
13+
const inputDirPath = join(basePath, inputDir || 'slides');
14+
const outputDirPath = join(basePath, outputDir || 'dist');
1515
let config = {};
1616

1717
try {

0 commit comments

Comments
 (0)