mirror of
https://github.com/wassname/nvatom.git
synced 2026-09-10 12:21:11 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb80f5e203 | ||
|
|
5f26638a78 |
@@ -1,3 +1,6 @@
|
|||||||
|
## 0.3.0
|
||||||
|
- Fix the bug that the default note directory is within packages directory. If it happens, it **deletes** all of existing notes. If you read this before updating the package, please check your note directory before updating it.
|
||||||
|
|
||||||
## 0.2.0
|
## 0.2.0
|
||||||
- Use DocQuery
|
- Use DocQuery
|
||||||
- Introduce autosave features
|
- Introduce autosave features
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ module.exports =
|
|||||||
title: 'Note Directory'
|
title: 'Note Directory'
|
||||||
description: 'The directory to archive notes'
|
description: 'The directory to archive notes'
|
||||||
type: 'string'
|
type: 'string'
|
||||||
default: process.env.ATOM_HOME + '/packages/notational-velocity/notebook'
|
default: path.join(process.env.ATOM_HOME, 'notational-velocity-notes')
|
||||||
|
|
||||||
notationalVelocityView: null
|
notationalVelocityView: null
|
||||||
|
|
||||||
activate: (state) ->
|
activate: (state) ->
|
||||||
@rootDirectory = fs.realpathSync(atom.config.get('notational-velocity.directory'))
|
@rootDirectory = @ensureNoteDirectory()
|
||||||
|
|
||||||
# Events subscribed to in atom's system can be easily cleaned up with a
|
# Events subscribed to in atom's system can be easily cleaned up with a
|
||||||
# CompositeDisposable
|
# CompositeDisposable
|
||||||
@@ -60,3 +60,25 @@ module.exports =
|
|||||||
|
|
||||||
autosaveAll: ->
|
autosaveAll: ->
|
||||||
@autosave(paneItem) for paneItem in atom.workspace.getPaneItems()
|
@autosave(paneItem) for paneItem in atom.workspace.getPaneItems()
|
||||||
|
|
||||||
|
ensureNoteDirectory: ->
|
||||||
|
noteDirectory = atom.config.get('notational-velocity.directory')
|
||||||
|
packagesDirectory = path.join(process.env.ATOM_HOME, 'packages')
|
||||||
|
defaultNoteDirectory = path.join(packagesDirectory, 'notational-velocity', 'notebook')
|
||||||
|
|
||||||
|
if noteDirectory.startsWith(packagesDirectory)
|
||||||
|
storageDirectory = path.join(packagesDirectory, 'storage')
|
||||||
|
throw new Error("""
|
||||||
|
The note directory (#{noteDirectory}) should NOT nest under #{packagesDirectory}.
|
||||||
|
It is likely that you updated the package to a newer version from v0.1.0.
|
||||||
|
It is likely that the note directory is overwritten.
|
||||||
|
Unfortunately, I couldn't find a way to recover overwritten notes.
|
||||||
|
You might recover partial notes from #{storageDirectory}.
|
||||||
|
I am extremely sorry.
|
||||||
|
- Seongjae Lee""")
|
||||||
|
|
||||||
|
if !fs.existsSync(noteDirectory)
|
||||||
|
fs.makeTreeSync(noteDirectory)
|
||||||
|
fs.copySync(defaultNoteDirectory, noteDirectory)
|
||||||
|
|
||||||
|
return fs.realpathSync(noteDirectory)
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "notational-velocity",
|
"name": "notational-velocity",
|
||||||
"main": "./lib/notational-velocity",
|
"main": "./lib/notational-velocity",
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Seongjae Lee <seongjae@gmail.com>",
|
"Seongjae Lee <seongjae@gmail.com>",
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
|
path = require 'path'
|
||||||
#
|
|
||||||
# To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
|
|
||||||
# or `fdescribe`). Remove the `f` to unfocus the block.
|
|
||||||
|
|
||||||
describe "NotationalVelocity", ->
|
describe "NotationalVelocity", ->
|
||||||
defaultDirectory = atom.config.get('notational-velocity.directory')
|
defaultDirectory = atom.config.get('notational-velocity.directory')
|
||||||
@@ -20,8 +17,7 @@ describe "NotationalVelocity", ->
|
|||||||
it "attaches and then detaches the view", ->
|
it "attaches and then detaches the view", ->
|
||||||
expect(workspaceElement.querySelector('.notational-velocity')).not.toExist()
|
expect(workspaceElement.querySelector('.notational-velocity')).not.toExist()
|
||||||
|
|
||||||
# This is an activation event, triggering it will cause the package to be
|
# This is an activation event, triggering it will cause the package to be activated.
|
||||||
# activated.
|
|
||||||
atom.commands.dispatch workspaceElement, 'notational-velocity:toggle'
|
atom.commands.dispatch workspaceElement, 'notational-velocity:toggle'
|
||||||
|
|
||||||
waitsForPromise ->
|
waitsForPromise ->
|
||||||
@@ -30,3 +26,24 @@ describe "NotationalVelocity", ->
|
|||||||
runs ->
|
runs ->
|
||||||
expect(workspaceElement.querySelector('.notational-velocity')).toExist()
|
expect(workspaceElement.querySelector('.notational-velocity')).toExist()
|
||||||
atom.commands.dispatch workspaceElement, 'notational-velocity:toggle'
|
atom.commands.dispatch workspaceElement, 'notational-velocity:toggle'
|
||||||
|
|
||||||
|
it "checks if we banned the default directory under packages directory", ->
|
||||||
|
atom.notifications.clear()
|
||||||
|
|
||||||
|
waitsForPromise ->
|
||||||
|
atom.packages.activatePackage('notifications')
|
||||||
|
|
||||||
|
runs ->
|
||||||
|
defaultNoteDirectory = path.join(process.env.ATOM_HOME, 'packages', 'notational-velocity', 'notebook')
|
||||||
|
atom.config.set('notational-velocity.directory', defaultNoteDirectory)
|
||||||
|
|
||||||
|
# This is an activation event, triggering it will cause the package to be activated.
|
||||||
|
atom.commands.dispatch workspaceElement, 'notational-velocity:toggle'
|
||||||
|
|
||||||
|
waitsForPromise ->
|
||||||
|
activationPromise
|
||||||
|
|
||||||
|
runs ->
|
||||||
|
notificationContainer = workspaceElement.querySelector('atom-notifications')
|
||||||
|
notification = notificationContainer.querySelector('atom-notification.fatal')
|
||||||
|
expect(notification).toExist()
|
||||||
|
|||||||
Reference in New Issue
Block a user