Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature/file watcher#50

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 5 commits intomasterfromfeature/file-watcher
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletionsrc/actions/setupActions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,15 +37,49 @@ const runCommands = async (commands: string[], language: string = 'JAVASCRIPT')
}
}

// collect active file watchers (listeners)
const watchers: {[key: string]: vscode.FileSystemWatcher} = {}

const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, commits, files}: G.StepActions): Promise<void> => {
const disposeWatcher = (listener: string) => {
watchers[listener].dispose()
delete watchers[listener]
}

const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, commits, files, listeners}: G.StepActions): Promise<void> => {
// run commits
if (commits) {
for (const commit of commits) {
await git.loadCommit(commit)
}
}

// run file watchers (listeners)
if (listeners) {
for (const listener of listeners) {
if (!watchers[listener]) {
const pattern = new vscode.RelativePattern(
vscode.workspace.getWorkspaceFolder(workspaceRoot.uri)!,
listener
)
watchers[listener] = vscode.workspace.createFileSystemWatcher(
pattern
)
watchers[listener].onDidChange(() => {
// trigger save
vscode.commands.executeCommand('coderoad.run_test', null, () => {
// cleanup watcher on success
disposeWatcher(listener)
})
})
}
}
} else {
// remove all watchers
for (const listener of Object.keys(watchers)) {
disposeWatcher(listener)
}
}

// run command
if (commands) {
await runCommands(commands)
Expand Down
3 changes: 2 additions & 1 deletionsrc/editor/commands.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,14 +54,15 @@ export const createCommands = ({extensionPath, workspaceState, workspaceRoot}: C
// set from last setup stepAction
currentStepId = stepId
},
[COMMANDS.RUN_TEST]: (current: {stepId: string} | undefined) => {
[COMMANDS.RUN_TEST]: (current: {stepId: string} | undefined, onSuccess: () => void) => {
console.log('-------- command.run_test ------ ')
// use stepId from client, or last set stepId
const payload = {stepId: current ? current.stepId : currentStepId}
runTest({
onSuccess: () => {
// send test pass message back to client
webview.send({type: 'TEST_PASS', payload})
onSuccess()
vscode.window.showInformationMessage('PASS')
},
onFail: () => {
Expand Down
8 changes: 2 additions & 6 deletionstypings/graphql.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,6 +133,7 @@ export type StepActions = {
commits: Array<Scalars['Sha1']>
files?: Maybe<Array<Scalars['String']>>
commands?: Maybe<Array<Scalars['String']>>
listeners?: Maybe<Array<Scalars['String']>>
}

export type TestRunner = 'JEST'
Expand DownExpand Up@@ -494,6 +495,7 @@ export type StepActionsResolvers<
commits?: Resolver<Array<ResolversTypes['Sha1']>, ParentType, ContextType>
files?: Resolver<Maybe<Array<ResolversTypes['String']>>, ParentType, ContextType>
commands?: Resolver<Maybe<Array<ResolversTypes['String']>>, ParentType, ContextType>
listeners?: Resolver<Maybe<Array<ResolversTypes['String']>>, ParentType, ContextType>
}

export type TutorialResolvers<
Expand DownExpand Up@@ -632,9 +634,3 @@ export interface IntrospectionResultData {
}[]
}
}
const result: IntrospectionResultData = {
__schema: {
types: [],
},
}
export default result
Loading

[8]ページ先頭

©2009-2025 Movatter.jp