Skip to content

Commit fb9dd58

Browse files
authored
add version ex command (#181)
1 parent 4af5537 commit fb9dd58

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "cm-runtests",
88
"static": "tsc --noEmit",
99
"testAll": "yarn run static && yarn run test && cd dev/cm5 && yarn run buildAndTest",
10-
"build": "cm-buildhelper src/index.ts",
10+
"build": "cm-buildhelper src/index.ts && node scripts/addVersion.cjs",
1111
"publish": "yarn run build && npm publish",
1212
"prepare": "yarn run build"
1313
},

scripts/addVersion.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var fs = require("fs")
2+
var json = fs.readFileSync(__dirname + "/../package.json", "utf-8")
3+
var version = JSON.parse(json).version
4+
5+
console.log(version)
6+
function replace(path) {
7+
var value = fs.readFileSync(path, "utf-8")
8+
value = value.replace("<DEV>", version);
9+
fs.writeFileSync(path, value , "utf-8")
10+
}
11+
12+
replace(__dirname + "/../dist/index.js")
13+
replace(__dirname + "/../dist/index.cjs")

src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export type vimOption = {
184184
}
185185

186186

187-
export type ExFn = ()=> void;
187+
export type ExFn = (cm: CodeMirrorV, params: ExParams)=> void;
188188

189189
type allCommands = {
190190
keys: string,

src/vim.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6247,6 +6247,10 @@ export function initVim(CodeMirror) {
62476247

62486248
var exCommandDispatcher = new ExCommandDispatcher();
62496249

6250+
vimApi.defineEx("version", "ve", (cm) => {
6251+
showConfirm(cm, "Codemirror-vim version: <DEV>");
6252+
});
6253+
62506254
/**
62516255
* @arg {CodeMirrorV} cm CodeMirror instance we are in.
62526256
* @arg {boolean} confirm Whether to confirm each replace.

0 commit comments

Comments
 (0)