diff --git a/extension.js b/extension.js index 2944408..573f512 100644 --- a/extension.js +++ b/extension.js @@ -1,4 +1,5 @@ const vscode = require('vscode'); +const endWithSemicolon = vscode.workspace.getConfiguration('ConsoleUtils', 'endWithSemicolon') const insertText = (val) => { const editor = vscode.window.activeTextEditor; @@ -51,6 +52,8 @@ function activate(context) { const insertLogStatement = vscode.commands.registerCommand('extension.insertLogStatement', () => { const editor = vscode.window.activeTextEditor; + const endWithSemicolon = vscode.workspace.getConfiguration('consoleUtils').endWithSemicolon; + if (!editor) { return; } const selection = editor.selection; @@ -59,7 +62,7 @@ function activate(context) { text ? vscode.commands.executeCommand('editor.action.insertLineAfter') .then(() => { - const logToInsert = `console.log('${text}: ', ${text});`; + const logToInsert = `console.log('${text}: ', ${text})${ endWithSemicolon ? ';' : '' }`; insertText(logToInsert); }) : insertText('console.log();'); @@ -85,6 +88,7 @@ function activate(context) { exports.activate = activate; function deactivate() { + } exports.deactivate = deactivate; diff --git a/package.json b/package.json index 49753e2..81fa405 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,17 @@ "key": "shift+ctrl+d", "mac": "shift+cmd+d" } - ] + ], + "configuration": { + "title": "ConsoleUtils", + "properties": { + "consoleUtils.endWithSemicolon": { + "type": "boolean", + "default": true, + "description": "Place a semicolon at the end of the console.log line." + } + } + } }, "scripts": { "postinstall": "node ./node_modules/vscode/bin/install",