From 19c75d74dd012bfacff507d3c3326d584a45ea88 Mon Sep 17 00:00:00 2001 From: Julian Di Leonardo <917764+jdileonardo@users.noreply.github.com> Date: Fri, 3 Jul 2020 14:01:02 -0400 Subject: [PATCH] Adding Support for only adding copyright for new files --- package-lock.json | 2 +- package.json | 5 +++++ src/configuration.ts | 4 ++++ src/copyright/copyrightService.ts | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b2987df..08cae3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "copyrighter", - "version": "0.0.2", + "version": "0.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8b2e9a0..e52dbd8 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,11 @@ "type": "string", "default": "", "description": "An optional note that can appear at the end of the default copyright notice." + }, + "copyrighter.newFilesOnly": { + "type": "boolean", + "default": false, + "description": "Inject Copyright notice in new files only" } } } diff --git a/src/configuration.ts b/src/configuration.ts index 98742e4..f6cfecb 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -57,3 +57,7 @@ export function getCopyright(): Copyright { export function getNote(): string { return getConfiguration().get('note') || ''; } + +export function getNewFilesOnly(): Boolean { + return getConfiguration().get('newFilesOnly') || false; +} diff --git a/src/copyright/copyrightService.ts b/src/copyright/copyrightService.ts index 6386024..3e1e10a 100644 --- a/src/copyright/copyrightService.ts +++ b/src/copyright/copyrightService.ts @@ -22,7 +22,7 @@ export function handleCopyrightCheck(editor: vscode.TextEditor | undefined) { if ( editor !== undefined && isSupportedLanguage(editor.document.languageId) && - !hasCopyright(editor.document) + !hasCopyright(editor.document) && (configuration.getNewFilesOnly() ? isNewDocument(editor.document) : true) ) { insertCopyright(editor); }