Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add version ex command #181

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -6216,6 +6216,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
Loading