-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules | |
.vscode-test/ | ||
*.vsix | ||
yarn-error.log | ||
VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ yarn-error.log | |
**/*.map | ||
**/*.ts | ||
node_modules | ||
VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ExtensionContext } from 'vscode'; | ||
import path from 'path'; | ||
|
||
import * as newVersionNotifier from './newVersionNotifier'; | ||
import { closeEditorsAndCleanWorkspace } from '../test/testUtils'; | ||
|
||
describe('newVersionNotifier extension', () => { | ||
beforeEach(closeEditorsAndCleanWorkspace); | ||
|
||
afterEach(closeEditorsAndCleanWorkspace); | ||
|
||
it('should not fail on activate', () => { | ||
expect(() => { | ||
console.log('test', path.resolve(path.join(__dirname, '..', '..'))); | ||
const mockContext = ({ | ||
subscriptions: [], | ||
extensionPath: path.resolve(path.join(__dirname, '..', '..')), | ||
} as unknown) as ExtensionContext; | ||
newVersionNotifier.activate(mockContext); | ||
mockContext.subscriptions.forEach((sub) => sub.dispose()); | ||
}).not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { window, commands, Uri, ExtensionContext } from 'vscode'; | ||
|
||
// Add new version teasers for showing notification on extension update | ||
const teasers: { [key: string]: string } = { | ||
'0.1.10': 'Memo v0.1.10! Links rename, opening links in the default app and more.', | ||
}; | ||
|
||
const showMeAction = 'Show Me'; | ||
|
||
export const activate = (context: ExtensionContext) => { | ||
try { | ||
const versionPath = path.join(context.extensionPath, 'VERSION'); | ||
const data = fs.readFileSync(path.join(context.extensionPath, 'package.json')).toString(); | ||
const currentVersion: string = JSON.parse(data).version; | ||
|
||
const teaserMsg = teasers[currentVersion]; | ||
|
||
if ( | ||
!teaserMsg || | ||
(fs.existsSync(versionPath) && fs.readFileSync(versionPath).toString() === currentVersion) | ||
) { | ||
return; | ||
} | ||
|
||
fs.writeFileSync(versionPath, currentVersion); | ||
|
||
window.showInformationMessage(teaserMsg, showMeAction, 'Dismiss').then((option) => { | ||
if (option === showMeAction) { | ||
commands.executeCommand( | ||
'vscode.open', | ||
Uri.parse('https:/svsool/vscode-memo/blob/master/CHANGELOG.md'), | ||
); | ||
} | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; |