Skip to content

Commit 55cb48e

Browse files
committed
meta: add prettier, .npmignore, and GitHub workflows
1 parent 2cf7fe4 commit 55cb48e

File tree

9 files changed

+589
-560
lines changed

9 files changed

+589
-560
lines changed

.github/workflows/commit.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Run ESLint, Prettier, and Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags-ignore:
7+
- '**'
8+
paths:
9+
- '**/*.js'
10+
jobs:
11+
test:
12+
if: "!contains(github.event.head_commit.message, 'skip ci')"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-node@v3
17+
with:
18+
node-version: 18
19+
- name: Installing dependencies
20+
run: npm install
21+
- name: Running Prettier
22+
run: npx prettier **/*.js --write
23+
- name: Commit
24+
uses: EndBug/add-and-commit@v9
25+
with:
26+
message: 'chore: prettier'
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
package-lock.json

.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.github/
2+
examples/
3+
plugins/

examples/consoleExample.js

+49-44
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,73 @@
1-
import { CommandHandler } from "../src/index.js";
1+
import { CommandHandler } from '../src/index.js';
22

33
/*
44
This example is a simple console commands handler
55
*/
66

77
let handler = new CommandHandler({
8-
prefix: "",
9-
buildArguments: (build) => [build.args],
8+
prefix: '',
9+
buildArguments: build => [build.args]
1010
});
1111

1212
handler.registerCommand({
13-
name: "help",
14-
desc: "Shows commands",
15-
async run(args) {
16-
handler.Commands.forEach((cmd) => {
17-
console.log("> " + cmd.name);
18-
console.log(" " + cmd.desc);
19-
console.log(" Usage: " + handler.prettyPrint(cmd));
20-
})
21-
},
13+
name: 'help',
14+
desc: 'Shows commands',
15+
async run(args) {
16+
handler.Commands.forEach(cmd => {
17+
console.log('> ' + cmd.name);
18+
console.log(' ' + cmd.desc);
19+
console.log(' Usage: ' + handler.prettyPrint(cmd));
20+
});
21+
}
2222
});
2323

2424
handler.registerCommand({
25-
name: "say",
26-
desc: "Repeats your words",
27-
args: [{
28-
type: "text",
29-
rest: true,
30-
}],
31-
async run([text]) {
32-
// Because rest: true, it all gets collected to the first element
33-
console.log(text);
34-
},
25+
name: 'say',
26+
desc: 'Repeats your words',
27+
args: [
28+
{
29+
type: 'text',
30+
rest: true
31+
}
32+
],
33+
async run([text]) {
34+
// Because rest: true, it all gets collected to the first element
35+
console.log(text);
36+
}
3537
});
3638

3739
handler.registerCommand({
38-
name: "add",
39-
desc: "Add two numbers",
40-
args: [{
41-
type: "number",
42-
name: "a",
43-
}, {
44-
type: "number",
45-
name: "b",
46-
}],
47-
async run([a, b]) {
48-
let sum = a + b;
49-
console.log(a + " + " + b + " = " + sum);
40+
name: 'add',
41+
desc: 'Add two numbers',
42+
args: [
43+
{
44+
type: 'number',
45+
name: 'a'
5046
},
47+
{
48+
type: 'number',
49+
name: 'b'
50+
}
51+
],
52+
async run([a, b]) {
53+
let sum = a + b;
54+
console.log(a + ' + ' + b + ' = ' + sum);
55+
}
5156
});
5257

5358
handler.registerCommand({
54-
name: "exit",
55-
desc: "Exit this example",
56-
async run() {
57-
console.log("OK, bye!");
58-
process.exit();
59-
},
59+
name: 'exit',
60+
desc: 'Exit this example',
61+
async run() {
62+
console.log('OK, bye!');
63+
process.exit();
64+
}
6065
});
6166

6267
var stdin = process.openStdin();
63-
stdin.addListener("data", (d) => {
64-
let input = d.toString().trim();
65-
handler.run(input);
68+
stdin.addListener('data', d => {
69+
let input = d.toString().trim();
70+
handler.run(input);
6671
});
6772

68-
handler.run("help");
73+
handler.run('help');

package-lock.json

-28
This file was deleted.

package.json

+11
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,16 @@
3030
"homepage": "https://github.com/TheAlan404/string-commands#readme",
3131
"dependencies": {
3232
"splitargs": "^0.0.7"
33+
},
34+
"devDependencies": {
35+
"prettier": "^2.6.2"
36+
},
37+
"prettier": {
38+
"semi": true,
39+
40+
"singleQuote": true,
41+
"trailingComma": "none",
42+
"arrowParens": "avoid",
43+
"htmlWhitespaceSensitivity": "ignore"
3344
}
3445
}

0 commit comments

Comments
 (0)