Skip to content

Commit

Permalink
add version ex command (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing authored Nov 4, 2024
1 parent 4af5537 commit fb9dd58
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
13 changes: 13 additions & 0 deletions scripts/addVersion.cjs
Original file line number Diff line number Diff line change
@@ -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("<DEV>", version);
fs.writeFileSync(path, value , "utf-8")
}

replace(__dirname + "/../dist/index.js")
replace(__dirname + "/../dist/index.cjs")
2 changes: 1 addition & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export type vimOption = {
}


export type ExFn = ()=> void;
export type ExFn = (cm: CodeMirrorV, params: ExParams)=> void;

type allCommands = {
keys: string,
Expand Down
4 changes: 4 additions & 0 deletions src/vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -6247,6 +6247,10 @@ export function initVim(CodeMirror) {

var exCommandDispatcher = new ExCommandDispatcher();

vimApi.defineEx("version", "ve", (cm) => {
showConfirm(cm, "Codemirror-vim version: <DEV>");
});

/**
* @arg {CodeMirrorV} cm CodeMirror instance we are in.
* @arg {boolean} confirm Whether to confirm each replace.
Expand Down

0 comments on commit fb9dd58

Please sign in to comment.