@sheplu/editorconfig 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +24 -2
- package/package.json +22 -22
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
4
5
|
|
|
5
6
|
const editorconfigContent = `root = true
|
|
6
7
|
|
|
@@ -23,7 +24,7 @@ export function createEditorConfig(path = '.editorconfig') {
|
|
|
23
24
|
|
|
24
25
|
export function compareEditorConfig(path = '.editorconfig') {
|
|
25
26
|
const file = readFileSync(path).toString();
|
|
26
|
-
if(editorconfigContent === file) {
|
|
27
|
+
if (editorconfigContent === file) {
|
|
27
28
|
console.log('✅ Editorconfig is matching the expected configuration')
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
@@ -32,7 +33,28 @@ export function compareEditorConfig(path = '.editorconfig') {
|
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
function main() {
|
|
35
|
-
|
|
36
|
+
const args = process.argv.slice(2);
|
|
37
|
+
const options = {
|
|
38
|
+
mode: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
short: 'm',
|
|
41
|
+
},
|
|
42
|
+
path: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
short: 'p',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const { values } = parseArgs({ args, options });
|
|
48
|
+
const path = values.path || '.editorconfig'
|
|
49
|
+
if (values.mode === 'write') {
|
|
50
|
+
createEditorConfig(path);
|
|
51
|
+
}
|
|
52
|
+
else if (values.mode === 'check') {
|
|
53
|
+
compareEditorConfig(path);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.error('invalide commande');
|
|
57
|
+
}
|
|
36
58
|
};
|
|
37
59
|
|
|
38
60
|
main();
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
"name": "@sheplu/editorconfig",
|
|
3
|
+
"version": "0.8.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"@sheplu/editorconfig": "index.js"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/sheplu/editorconfig.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/sheplu/editorconfig/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/sheplu/editorconfig#readme"
|
|
24
24
|
}
|