@chriswiegman/hugo-tools 0.2.0 → 0.2.2

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/src/vscode.js CHANGED
@@ -20,86 +20,89 @@ const { requireHugoSite, vscodeDir } = require('./config');
20
20
  const { main: extractTags } = require('./extract-tags');
21
21
 
22
22
  const TASKS = {
23
- "version": "2.0.0",
24
- "tasks": [
25
- {
26
- "label": "Create Draft",
27
- "type": "shell",
28
- "command": "npx draft",
29
- "problemMatcher": []
30
- },
31
- {
32
- "label": "Add Tags",
33
- "type": "shell",
34
- "command": "npx add-tags",
35
- "problemMatcher": []
36
- },
37
- {
38
- "label": "Publish Draft (now)",
39
- "type": "shell",
40
- "command": "output=$(npx publish \"${relativeFile}\" now); echo \"$output\"; newFile=$(echo \"$output\" | grep -oE 'content/[^ ]+\\.md'); [ -n \"$newFile\" ] && code -r \"${workspaceFolder}/$newFile\"",
41
- "problemMatcher": []
42
- },
43
- {
44
- "label": "Publish Draft (later)",
45
- "type": "shell",
46
- "command": "read -p \"Publish date (YYYY-MM-DD): \" d; output=$(npx publish \"${relativeFile}\" later \"$d\"); echo \"$output\"; newFile=$(echo \"$output\" | grep -oE 'content/[^ ]+\\.md'); [ -n \"$newFile\" ] && code -r \"${workspaceFolder}/$newFile\"",
47
- "problemMatcher": []
48
- },
49
- {
50
- "label": "Pick Image",
51
- "type": "shell",
52
- "command": "read -p 'Image path: ' img; npx pick-image \"$img\" \"${relativeFile}\"",
53
- "problemMatcher": [],
54
- "presentation": {
55
- "focus": true
56
- }
57
- }
58
- ],
23
+ 'version': '2.0.0',
24
+ 'tasks': [
25
+ {
26
+ 'label': 'Create Draft',
27
+ 'type': 'shell',
28
+ 'command': 'npx draft',
29
+ 'problemMatcher': [],
30
+ },
31
+ {
32
+ 'label': 'Add Tags',
33
+ 'type': 'shell',
34
+ 'command': 'npx add-tags',
35
+ 'problemMatcher': [],
36
+ },
37
+ {
38
+ 'label': 'Publish Draft (now)',
39
+ 'type': 'shell',
40
+ 'command': 'output=$(npx publish "${relativeFile}" now); echo "$output"; newFile=$(echo "$output" | grep -oE \'content/[^ ]+\\.md\'); [ -n "$newFile" ] && code -r "${workspaceFolder}/$newFile"',
41
+ 'problemMatcher': [],
42
+ },
43
+ {
44
+ 'label': 'Publish Draft (later)',
45
+ 'type': 'shell',
46
+ 'command': 'read -p "Publish date (YYYY-MM-DD): " d; output=$(npx publish "${relativeFile}" later "$d"); echo "$output"; newFile=$(echo "$output" | grep -oE \'content/[^ ]+\\.md\'); [ -n "$newFile" ] && code -r "${workspaceFolder}/$newFile"',
47
+ 'problemMatcher': [],
48
+ },
49
+ {
50
+ 'label': 'Pick Image',
51
+ 'type': 'shell',
52
+ 'command': 'read -p \'Image path: \' img; npx pick-image "$img" "${relativeFile}"',
53
+ 'problemMatcher': [],
54
+ 'presentation': {
55
+ 'focus': true,
56
+ },
57
+ },
58
+ ],
59
59
  };
60
60
 
61
61
  const EXTENSIONS = {
62
- recommendations: [
63
- 'chriswiegman.cw-markdown-word-count',
64
- 'streetsidesoftware.code-spell-checker',
65
- ],
62
+ recommendations: [
63
+ 'chriswiegman.cw-markdown-word-count',
64
+ 'streetsidesoftware.code-spell-checker',
65
+ ],
66
66
  };
67
67
 
68
68
  const SETTINGS = {
69
- '[markdown]': {
70
- 'editor.quickSuggestions': {
71
- comments: false,
72
- other: false,
73
- strings: true,
74
- },
75
- 'editor.snippetSuggestions': 'top',
76
- 'editor.suggest.showSnippets': true,
77
- 'editor.wordBasedSuggestions': 'off',
78
- },
79
- 'workbench.editor.closeOnFileDelete': true,
69
+ '[markdown]': {
70
+ 'editor.quickSuggestions': {
71
+ comments: false,
72
+ other: false,
73
+ strings: true,
74
+ },
75
+ 'editor.snippetSuggestions': 'top',
76
+ 'editor.suggest.showSnippets': true,
77
+ 'editor.wordBasedSuggestions': 'off',
78
+ },
79
+ 'workbench.editor.closeOnFileDelete': true,
80
80
  };
81
81
 
82
82
  function writeIfAbsent(filePath, content) {
83
- const rel = path.relative(process.cwd(), filePath);
84
- if (fs.existsSync(filePath)) {
85
- console.log(` skipped ${rel} (already exists)`);
86
- return;
87
- }
88
- fs.writeFileSync(filePath, content, 'utf8');
89
- console.log(` created ${rel}`);
83
+ const rel = path.relative(process.cwd(), filePath);
84
+
85
+ if (fs.existsSync(filePath)) {
86
+ console.log(` skipped ${rel} (already exists)`);
87
+ return;
88
+ }
89
+
90
+ fs.writeFileSync(filePath, content, 'utf8');
91
+ console.log(` created ${rel}`);
90
92
  }
91
93
 
92
94
  function main() {
93
- requireHugoSite();
95
+ requireHugoSite();
96
+
97
+ const dir = path.join(process.cwd(), vscodeDir);
94
98
 
95
- const dir = path.join(process.cwd(), vscodeDir);
96
- fs.mkdirSync(dir, { recursive: true });
99
+ fs.mkdirSync(dir, { recursive: true });
97
100
 
98
- writeIfAbsent(path.join(dir, 'tasks.json'), JSON.stringify(TASKS, null, 2) + '\n');
99
- writeIfAbsent(path.join(dir, 'extensions.json'), JSON.stringify(EXTENSIONS, null, 2) + '\n');
100
- writeIfAbsent(path.join(dir, 'settings.json'), JSON.stringify(SETTINGS, null, 2) + '\n');
101
+ writeIfAbsent(path.join(dir, 'tasks.json'), JSON.stringify(TASKS, null, 2) + '\n');
102
+ writeIfAbsent(path.join(dir, 'extensions.json'), JSON.stringify(EXTENSIONS, null, 2) + '\n');
103
+ writeIfAbsent(path.join(dir, 'settings.json'), JSON.stringify(SETTINGS, null, 2) + '\n');
101
104
 
102
- extractTags();
105
+ extractTags();
103
106
  }
104
107
 
105
108
  main();