diff --git a/package.json b/package.json index 8df2d82..1d6b3d3 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "test": "cm-runtests", "static": "tsc --noEmit", "testAll": "yarn run static && yarn run test && cd dev/cm5 && yarn run buildAndTest", - "build": "cm-buildhelper src/index.ts", + "build": "cm-buildhelper src/index.ts && node scripts/addVersion.cjs", "publish": "yarn run build && npm publish", "prepare": "yarn run build" }, diff --git a/scripts/addVersion.cjs b/scripts/addVersion.cjs new file mode 100644 index 0000000..718dae8 --- /dev/null +++ b/scripts/addVersion.cjs @@ -0,0 +1,13 @@ +var fs = require("fs") +var json = fs.readFileSync(__dirname + "/../package.json", "utf-8") +var version = JSON.parse(json).version + +console.log(version) +function replace(path) { + var value = fs.readFileSync(path, "utf-8") + value = value.replace("", version); + fs.writeFileSync(path, value , "utf-8") +} + +replace(__dirname + "/../dist/index.js") +replace(__dirname + "/../dist/index.cjs") \ No newline at end of file diff --git a/src/types.d.ts b/src/types.d.ts index 289957b..f271162 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -184,7 +184,7 @@ export type vimOption = { } -export type ExFn = ()=> void; +export type ExFn = (cm: CodeMirrorV, params: ExParams)=> void; type allCommands = { keys: string, diff --git a/src/vim.js b/src/vim.js index 31e5f61..d0e299f 100644 --- a/src/vim.js +++ b/src/vim.js @@ -6216,6 +6216,10 @@ export function initVim(CodeMirror) { var exCommandDispatcher = new ExCommandDispatcher(); + vimApi.defineEx("version", "ve", (cm) => { + showConfirm(cm, "Codemirror-vim version: "); + }); + /** * @arg {CodeMirrorV} cm CodeMirror instance we are in. * @arg {boolean} confirm Whether to confirm each replace.