Skip to content

Commit

Permalink
Use dedent package for dedenting controller template
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth committed Oct 21, 2023
1 parent e6be880 commit f809f16
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"scripts": {},
"dependencies": {
"@hotwired/stimulus": "https://github.com/hotwired/dev-builds/archive/refs/tags/@hotwired/stimulus/8cbca6d.tar.gz",
"dedent": "^1.5.1",
"stimulus-parser": "^0.0.11",
"typescript": "^5.2.2",
"vscode-html-languageservice": "^4.0.5",
Expand Down
18 changes: 11 additions & 7 deletions server/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import dedent from "dedent"

import { Connection, TextDocumentEdit, TextEdit, CreateFile, Range, Diagnostic } from "vscode-languageserver/node"

import { Project, ControllerDefinition } from "stimulus-parser"
Expand Down Expand Up @@ -58,12 +60,14 @@ export class Commands {
}

private controllerTemplateFor(identifier: string) {
return `import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
console.log("${identifier} controller connected")
}
}`
return dedent`
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
console.log("${identifier} controller connected")
}
}
`
}
}
5 changes: 5 additions & 0 deletions server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ cross-spawn@^7.0.0:
shebang-command "^2.0.0"
which "^2.0.1"

dedent@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.5.1.tgz#4f3fc94c8b711e9bb2800d185cd6ad20f2a90aff"
integrity sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==

eastasianwidth@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb"
Expand Down

0 comments on commit f809f16

Please sign in to comment.