tldraw/apps/vscode/extension/src/extension.ts
Steve Ruiz a3c39cde4b
replace console.log with nicelog (#1496)
This PR replaces our `console.log` with `nicelog` so that I can more
easily grep for errant console.logs.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-06-01 18:01:49 +00:00

36 lines
1.1 KiB
TypeScript

import { watch } from 'fs'
import path from 'path'
import * as vscode from 'vscode'
import { TldrawEditorProvider } from './TldrawEditorProvider'
import { nicelog } from './utils'
export function activate(context: vscode.ExtensionContext) {
try {
if (process.env.NODE_ENV !== 'production') {
const extensionWatcher = watch(
__dirname + '/extension.js',
{ persistent: false },
(eventType, filename) => {
nicelog('reloading[%s]', eventType, filename)
extensionWatcher.close()
vscode.commands.executeCommand('workbench.action.reloadWindow')
}
)
const result = path.dirname(__dirname).split(path.sep).slice(1, -1)
const editorpath = path.join(...result)
const editorWatcher = watch(
editorpath + '/editor/index.js',
{ persistent: false },
(eventType, filename) => {
nicelog('reloading[%s]', eventType, filename)
editorWatcher.close()
vscode.commands.executeCommand('workbench.action.reloadWindow')
}
)
}
context.subscriptions.push(TldrawEditorProvider.register(context))
} catch (e) {
console.error(e)
}
}