@sheplu/editorconfig 0.6.0 → 0.8.0

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +34 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  A small CLI to manage a **consistent `.editorconfig`** across your projects.
4
4
 
5
5
  - ✅ Generate a sane default `.editorconfig` in seconds
6
- - 🔜 Check if your existing file matches the target setup
6
+ - Check if your existing file matches the target setup
7
7
  - 🔜 Propose updates (with confirmation) instead of blindly overwriting
8
8
  - 🔜 Compare your file against the recommended template
9
9
 
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { writeFileSync } from "node:fs";
3
+ import { readFileSync, writeFileSync } from "node:fs";
4
+ import { parseArgs } from 'node:util';
4
5
 
5
6
  const editorconfigContent = `root = true
6
7
 
@@ -21,8 +22,39 @@ export function createEditorConfig(path = '.editorconfig') {
21
22
  writeFileSync(path, editorconfigContent, 'utf8');
22
23
  };
23
24
 
25
+ export function compareEditorConfig(path = '.editorconfig') {
26
+ const file = readFileSync(path).toString();
27
+ if (editorconfigContent === file) {
28
+ console.log('✅ Editorconfig is matching the expected configuration')
29
+ }
30
+ else {
31
+ console.log('❌ Editorconfig is not matching the expected configuration');
32
+ }
33
+ };
34
+
24
35
  function main() {
25
- createEditorConfig();
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
+ }
26
58
  };
27
59
 
28
60
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheplu/editorconfig",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {