New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:Random Note Command #813
Conversation
1075b56
to
dbe0087
Compare
packages/plugin-core/package.json
Outdated
@@ -1,752 +1,757 @@ | |||
{ | |||
"name": "@dendronhq/plugin-core", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops - did we do some 'prettier' or whitespace formatting changes recently to this file? The only material difference should be the addition of
{
"command": "dendron.randomNote",
"title": "Dendron: Random Note",
"desc": "Open a Random Note"
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we did some formatting. no worries about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok to merge as is? or would you prefer me to re-align to the whitespace changes currently in master?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update the package generation code? specifically this should be changed to 2 spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
packages/plugin-core/package.json
Outdated
@@ -1,752 +1,757 @@ | |||
{ | |||
"name": "@dendronhq/plugin-core", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we did some formatting. no worries about this
|
||
type CommandInput = {}; | ||
|
||
type CommandOutput = void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a convention we've been following is to return the note as an output. makes it easy to test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, will adjust
} | ||
|
||
let isMatch = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: prefer forEach
syntax for conciseness. eg. includeSet.forEach( pattern => { ... } )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm - doesn't seem like you can call break
from within an interable.forEach() loop though: https://stackoverflow.com/questions/2641347/short-circuit-array-foreach-like-calling-break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good catch. in that case, feel free to use for
or use _.some
(we make liberal use of lodash as our utility library) https://lodash.com/docs/#some
} from "../testUtilsV3"; | ||
|
||
// common template function for RandomNoteCommand testing | ||
function basicTest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer object notation for function argument for readability. see https://wiki.dendron.so/notes/773e0b5a-510f-4c21-acf4-2d1ab3ed741e.html#prefer-using-object-notation-for-methods-ith-multiple-arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, new to Typescript - when I tried to switch to object notation, the parameters can no longer be referenced within runLegacyMultiWorkspaceTest()
. Seems that the properties of opts aren't known in that context (Error is Object literal may only specify known properties, and 'opts' does not exist in type 'SetupCodeConfigurationV2...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... how did you do it? it should look like the following:
basicTest({ctx, preSetupHook, ...}: {
ctx: ...
preSetupHook: ...
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean now - adjusted
ctx, | ||
preSetupHook: async ({ wsRoot, vaults }) => { | ||
for (let name of noteNames) { | ||
await CreateNoteFactory({ fname: name, body: "" }).create({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of exporting note factoring, you can use NoteTestUtilsV4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, will adjust and remove the export.
Fixes #743
New Command to navigate to a random note.