Skip to content

Commit

Permalink
Adding Support for only adding copyright for new files
Browse files Browse the repository at this point in the history
  • Loading branch information
jdileonardo authored and max-wilkinson committed Apr 1, 2021
1 parent 26f2274 commit 19c75d7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/copyright/copyrightService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 19c75d7

Please sign in to comment.