Skip to content

Commit 0474087

Browse files
committed
feat: runOnSave feature
1 parent c3be641 commit 0474087

File tree

7 files changed

+209
-41
lines changed

7 files changed

+209
-41
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
"@types/jsonfile": "^6.0.1",
184184
"@types/node": "^16.11.22",
185185
"@zardoy/utils": "^0.0.4",
186-
"@zardoy/vscode-utils": "^0.0.2",
186+
"@zardoy/vscode-utils": "^0.0.6",
187187
"algoliasearch": "^4.12.1",
188188
"change-case": "^4.1.2",
189189
"cross-env": "^7.0.3",

pnpm-lock.yaml

Lines changed: 41 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/configurationType.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44
// "title": "Open package.json from..."
55
// },
66
// enforcePackageManagerUse
7+
8+
type RunOnSaveRule = {
9+
relativePathGlob: string
10+
command: string,
11+
deps?: Array<string | {dep: string, type: string}>
12+
/**
13+
* Note for `packageJson`: it will fallback to file if closest package.json cannot be find
14+
* @default file */
15+
cwd?: 'file' | 'packageJson' | 'workspace'
16+
// TODO!
17+
/** Checks against locally installed version from node_modules. Raises a warning by default, if */
18+
// semverRange?: string
19+
/** Only when `semverRange` is specified */
20+
// noInstalledWarning?: boolean
21+
/** Kill previous command execution @default true */
22+
killPrev: boolean,
23+
}
24+
725
export type Configuration = {
826
// TOOD describe difference between builtin setting
927
/**
@@ -158,6 +176,12 @@ export type Configuration = {
158176
* @default true
159177
*/
160178
'codeAction.resolveBranchName': boolean
179+
'runOnSave': RunOnSaveRule[]
180+
/**
181+
* It won't run on after delay auto save type anyway
182+
* @default false
183+
*/
184+
'runOnSave.runOnAutoSave': ''
161185
/** @default true */
162186
// scriptsCompletion: boolean
163187
/** @default true */

src/configurationTypeCache.jsonc

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// GENERATED. DON'T EDIT MANUALLY
2-
// md5hash: 1d693afb4e91b66ba5c09b32da9e9502
2+
// md5hash: 853b6cfde74a5b1738b7b1e7c62e5e9d
33
{
44
"type": "object",
55
"properties": {
@@ -189,6 +189,72 @@
189189
"description": "Disable if action open repository takes a lot of time, in this case it would use `master` branch in url",
190190
"default": true,
191191
"type": "boolean"
192+
},
193+
"runOnSave": {
194+
"type": "array",
195+
"items": {
196+
"type": "object",
197+
"properties": {
198+
"relativePathGlob": {
199+
"type": "string"
200+
},
201+
"command": {
202+
"type": "string"
203+
},
204+
"deps": {
205+
"type": "array",
206+
"items": {
207+
"anyOf": [
208+
{
209+
"type": "object",
210+
"properties": {
211+
"dep": {
212+
"type": "string"
213+
},
214+
"type": {
215+
"type": "string"
216+
}
217+
},
218+
"required": [
219+
"dep",
220+
"type"
221+
]
222+
},
223+
{
224+
"type": "string"
225+
}
226+
]
227+
}
228+
},
229+
"cwd": {
230+
"description": "Note for `packageJson`: it will fallback to file if closest package.json cannot be find",
231+
"default": "file",
232+
"enum": [
233+
"file",
234+
"packageJson",
235+
"workspace"
236+
],
237+
"type": "string"
238+
},
239+
"killPrev": {
240+
"description": "Kill previous command execution @default true",
241+
"type": "boolean"
242+
}
243+
},
244+
"required": [
245+
"command",
246+
"killPrev",
247+
"relativePathGlob"
248+
]
249+
}
250+
},
251+
"runOnSave.runOnAutoSave": {
252+
"description": "It won't run on after delay auto save type anyway",
253+
"default": false,
254+
"type": "string",
255+
"enum": [
256+
""
257+
]
192258
}
193259
},
194260
"required": [
@@ -204,6 +270,8 @@
204270
"leadingPackageManager",
205271
"packageManagerAllowedEnv",
206272
"runBinCommand.searchLocation",
273+
"runOnSave",
274+
"runOnSave.runOnAutoSave",
207275
"scripts.mainScripts",
208276
"scripts.matchContents",
209277
"scripts.restartDelay",

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { registerClipboardDetection } from './core/clipboardDetection'
1717
import { activateStatusbar } from './features/statusbar'
1818
import { registerPackageJsonAutoComplete } from './packageJsonAutoComplete'
1919
import { startSpecialCommand } from './commands/startSpecialCommand'
20+
import { registerRunOnSave } from './features/runOnSave'
2021

2122
// TODO command for package diff
2223

@@ -49,6 +50,7 @@ export const activate = () => {
4950
registerClipboardDetection()
5051
registerPackageJsonAutoComplete()
5152
activateStatusbar()
53+
registerRunOnSave()
5254

5355
if (vscode.workspace.workspaceFolders?.length === 1) void workspaceOpened(vscode.workspace.workspaceFolders[0]!.uri)
5456

0 commit comments

Comments
 (0)