Skip to content

Commit 20800d7

Browse files
Add command update.
With the command `onepunch update` the user will update files in the `src` directory according to the latest release of onepunch. Please note that any custom change inside directory `src` will be overwritten. In order to prevent accidental deletions, the command ckecks the presence of file `onepunch.json`, if the file is not present the command aborts.
1 parent fb4fa3e commit 20800d7

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

index.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ const cli = meow({
2222
onepunch print [-i htmlfile] [-o pdffile]
2323
Print the presentation in a PDF file.
2424
25+
onepunch update
26+
Update files in the src directory according to the latest release.
27+
Please note that any custom change inside directory src will be overwritten
28+
2529
OPTIONS
2630
-n or --name directory_name
2731
Specify the name of the directory where the project is initialized. Defaults to onepunch-presentation.
28-
32+
2933
-i or --input htmlfile
3034
Specify the HTML file to print, defaults to "index.html".
31-
35+
3236
-o or --output pdffile
3337
Specify the name of the PDF file in output, defaults to "index.pdf".
3438
@@ -67,6 +71,9 @@ switch (cli.input[0]) {
6771
case 'print':
6872
print(cli.flags);
6973
break;
74+
case 'update':
75+
update();
76+
break;
7077
default:
7178
cli.showHelp();
7279
break;
@@ -94,6 +101,20 @@ function init(flags) {
94101
fs.copySync(path.resolve(__dirname, 'template'), presentationPath);
95102
}
96103

104+
function update() {
105+
const file = 'onepunch.json';
106+
107+
if (!fs.existsSync(file)) {
108+
abort('File onepunch.json is not present. Are you sure this is the right directory?');
109+
}
110+
111+
fs.copySync(
112+
path.resolve(__dirname, 'template/src'),
113+
'src',
114+
{overwrite: true},
115+
);
116+
}
117+
97118
function print(flags) {
98119
const {input, output} = flags;
99120

readme.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ $ npm install -g @nextbitlabs/onepunch
1616

1717
Please note that onepunch makes use of [puppeteer](https://github.com/puppeteer/puppeteer/), which will download chromium. This is necessary to print the PDF file.
1818

19+
Update **onepunch** to the latest release with:
20+
21+
```
22+
$ npm update -g @nextbitlabs/onepunch
23+
```
24+
1925
### Create a project
2026

2127
```
@@ -42,6 +48,21 @@ Inside the project directory, run:
4248
$ onepunch print
4349
```
4450

51+
### Update
52+
53+
Update files in the `src` directory according to the latest release of **onepunch**, please note that any custom change inside directory `src` will be overwritten:
54+
55+
```
56+
$ onepunch update
57+
```
58+
59+
The above command assumes you have installed the latest release of **onepunch**.
60+
If this is not the case, update **onepunch** to the latest release with:
61+
62+
```
63+
$ npm update -g @nextbitlabs/onepunch
64+
```
65+
4566
### Create custom styles
4667

4768
Each slide is created by means of tag `article`, for example:

template/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ Print the presentation in a PDF file with:
1111
```
1212
$ onepunch print
1313
```
14+
15+
Update files in the `src` directory according to the latest release:
16+
17+
```
18+
$ onepunch update
19+
```

0 commit comments

Comments
 (0)