Skip to content

Commit 207f2b3

Browse files
authored
Merge pull request #9 from bisterix-studio/docs-refine
Refine references and register docs in Parley main view
2 parents b813b8f + cf1d7a6 commit 207f2b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+273
-171
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
},
5656
"css.customData": [
5757
".vscode/tailwind.json"
58-
]
58+
],
59+
"markdown.extension.toc.updateOnSave": false
5960
}

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ Installation Features Examples Support Useful links Licence Contributions
5454
- Easy management of your Dialogue Sequences, including node filtering
5555
- Export your Dialogue passages to CSV
5656

57+
## Upcoming Features
58+
59+
Here are some key features on the Parley horizon. We are always open to new
60+
ideas, please don't hesitate to
61+
[get-in-touch](https://github.com/bisterix-studio/parley/issues).
62+
63+
- Translation support
64+
- Jump Nodes
65+
- Dialogue text expressions
66+
5767
## Installation
5868

5969
You can install it via the Asset Library or

addons/parley/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ Installation Features Examples Support Useful links Licence Contributions
5454
- Easy management of your Dialogue Sequences, including node filtering
5555
- Export your Dialogue passages to CSV
5656

57+
## Upcoming Features
58+
59+
Here are some key features on the Parley horizon. We are always open to new
60+
ideas, please don't hesitate to
61+
[get-in-touch](https://github.com/bisterix-studio/parley/issues).
62+
63+
- Translation support
64+
- Jump Nodes
65+
- Dialogue text expressions
66+
5767
## Installation
5868

5969
You can install it via the Asset Library or

addons/parley/main_panel.gd

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var parley_manager: ParleyManager
3737

3838
@onready var file_menu: MenuButton = %FileMenu
3939
@onready var insert_menu: MenuButton = %InsertMenu
40+
@onready var docs_button: Button = %DocsButton
4041
@onready var new_dialogue_modal: Window = %NewDialogueModal
4142
@onready var export_to_csv_modal: ParleyExportToCsvModal = %ExportToCsvModal
4243
@onready var editor: HSplitContainer = %EditorView
@@ -177,18 +178,29 @@ func _on_dialogue_ast_changed(new_dialogue_ast: ParleyDialogueSequenceAst) -> vo
177178
sidebar.current_dialogue_ast = new_dialogue_ast
178179
#endregion
179180

181+
182+
#region RENDERERS
183+
func _render_toolbar() -> void:
184+
# TODO: we might need to register this dynamically at a later date
185+
# it seems that it only does this at the project level atm.
186+
save_button.tooltip_text = &"Save the current Dialogue Sequence."
187+
188+
arrange_nodes_button.tooltip_text = &"Arrange the current Dialogue Sequence nodes."
189+
190+
refresh_button.tooltip_text = &"Refresh the current Dialogue Sequence."
191+
192+
docs_button.icon = get_theme_icon("Help", "EditorIcons")
193+
docs_button.text = &"Docs"
194+
docs_button.tooltip_text = &"Navigate to the Parley Documentation."
195+
docs_button.flat = true
196+
#endregion
197+
198+
180199
#region SETUP
181200
func _setup() -> void:
182201
_setup_file_menu()
183202
_setup_insert_menu()
184-
_setup_theme()
185-
186-
func _setup_theme() -> void:
187-
# TODO: we might need to register this dynamically at a later date
188-
# it seems that it only does this at the project level atm.
189-
save_button.tooltip_text = "Save the current Dialogue Sequence."
190-
arrange_nodes_button.tooltip_text = "Arrange the current Dialogue Sequence nodes."
191-
refresh_button.tooltip_text = "Refresh the current Dialogue Sequence."
203+
_render_toolbar()
192204

193205

194206
## Set up the file menu
@@ -584,6 +596,13 @@ func _on_bottom_panel_sidebar_toggled(is_sidebar_open: bool) -> void:
584596
sidebar.show()
585597
else:
586598
sidebar.hide()
599+
600+
601+
func _on_docs_button_pressed() -> void:
602+
var href: StringName = &"https://parley.bisterixstudio.com"
603+
var result: int = OS.shell_open(href)
604+
if result != OK:
605+
ParleyUtils.log.error("Unable to navigate to Parley Documentation at %s: %s" % [href, result])
587606
#endregion
588607

589608

addons/parley/main_panel.tscn

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=35 format=3 uid="uid://ckubjbp3e7yy3"]
1+
[gd_scene load_steps=38 format=3 uid="uid://ckubjbp3e7yy3"]
22

33
[ext_resource type="Script" uid="uid://ctp441gxhvg80" path="res://addons/parley/main_panel.gd" id="1_06n3w"]
44
[ext_resource type="Texture2D" uid="uid://ct6iywe1qjuh3" path="res://addons/parley/assets/New.svg" id="3_4ui00"]
@@ -31,6 +31,12 @@
3131
[ext_resource type="Script" uid="uid://3nqtsewsmim0" path="res://addons/parley/models/node_ast.gd" id="31_tp54n"]
3232
[ext_resource type="Script" uid="uid://btn7s5anok7p4" path="res://addons/parley/models/dialogue_ast.gd" id="32_pogw7"]
3333

34+
[sub_resource type="Resource" id="Resource_xjep8"]
35+
script = ExtResource("32_pogw7")
36+
title = ""
37+
edges = Array[ExtResource("30_rspbv")]([])
38+
nodes = Array[ExtResource("31_tp54n")]([])
39+
3440
[sub_resource type="Resource" id="Resource_s5oy3"]
3541
script = ExtResource("26_anq7l")
3642
actions = Array[ExtResource("9_anq7l")]([])
@@ -46,6 +52,18 @@ script = ExtResource("28_anq7l")
4652
characters = Array[ExtResource("11_7jaih")]([])
4753
id = ""
4854

55+
[sub_resource type="Image" id="Image_xjep8"]
56+
data = {
57+
"data": PackedByteArray(255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 42, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 93, 93, 41, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 92, 92, 0, 255, 92, 92, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 93, 93, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0),
58+
"format": "RGBA8",
59+
"height": 16,
60+
"mipmaps": false,
61+
"width": 16
62+
}
63+
64+
[sub_resource type="ImageTexture" id="ImageTexture_7jaih"]
65+
image = SubResource("Image_xjep8")
66+
4967
[sub_resource type="Resource" id="Resource_7hjis"]
5068
script = ExtResource("32_pogw7")
5169
title = ""
@@ -63,6 +81,7 @@ grow_vertical = 2
6381
size_flags_horizontal = 3
6482
size_flags_vertical = 3
6583
script = ExtResource("1_06n3w")
84+
dialogue_ast = SubResource("Resource_xjep8")
6685
action_store = SubResource("Resource_s5oy3")
6786
fact_store = SubResource("Resource_kaj3b")
6887
character_store = SubResource("Resource_h2jtb")
@@ -218,6 +237,20 @@ flat = true
218237
[node name="VSeparator3" type="VSeparator" parent="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar"]
219238
layout_mode = 2
220239

240+
[node name="Misc" type="HBoxContainer" parent="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar"]
241+
layout_mode = 2
242+
size_flags_horizontal = 3
243+
alignment = 2
244+
245+
[node name="VSeparator4" type="VSeparator" parent="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/Misc"]
246+
layout_mode = 2
247+
248+
[node name="DocsButton" type="Button" parent="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/Misc"]
249+
unique_name_in_owner = true
250+
layout_mode = 2
251+
text = "Docs"
252+
icon = SubResource("ImageTexture_7jaih")
253+
221254
[node name="EditorView" type="HSplitContainer" parent="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer"]
222255
unique_name_in_owner = true
223256
layout_mode = 2
@@ -264,6 +297,7 @@ dialogue_ast = SubResource("Resource_7hjis")
264297
[connection signal="pressed" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/EditorActions/RefreshButton" to="." method="_on_refresh_button_pressed"]
265298
[connection signal="pressed" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/Testing/TestDialogueFromStartButton" to="." method="_on_test_dialogue_from_start_button_pressed"]
266299
[connection signal="pressed" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/Testing/TestDialogueFromSelectedButton" to="." method="_on_test_dialogue_from_selected_button_pressed"]
300+
[connection signal="pressed" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/Toolbar/Misc/DocsButton" to="." method="_on_docs_button_pressed"]
267301
[connection signal="dialogue_ast_selected" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/EditorView/Sidebar" to="." method="_on_sidebar_dialogue_ast_selected"]
268302
[connection signal="node_selected" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/EditorView/Sidebar" to="." method="_on_sidebar_node_selected"]
269303
[connection signal="connection_request" from="MarginContainer/MainContainer/HSplitContainer/MainViewPanel/MainViewContainer/EditorView/GraphContainer/GraphView" to="." method="_on_graph_view_connection_request"]

addons/parley/parley_runtime.gd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@ static func get_instance() -> ParleyRuntime:
2121
#region GAME
2222
## Start a dialogue session with the provided Dialogue AST
2323
## Example: parley_runtime.start_dialogue(dialogue)
24-
func start_dialogue(ctx: Dictionary, dialogue_ast: ParleyDialogueSequenceAst, start_node: ParleyNodeAst = null) -> Node:
24+
func start_dialogue(ctx: Dictionary, dialogue_sequence_ast: ParleyDialogueSequenceAst, start_node: ParleyNodeAst = null) -> Node:
2525
# TODO: maybe pass this in instead of getting from the engine - gives us a bit more flexibility
26-
var current_scene: Node = get_current_scene()
26+
var current_scene: Node = _get_current_scene()
2727
var dialogue_balloon_path: String = ParleySettings.get_setting(ParleyConstants.DIALOGUE_BALLOON_PATH)
2828
if not ResourceLoader.exists(dialogue_balloon_path):
2929
ParleyUtils.log.info("Dialogue balloon does not exist at: %s. Falling back to default balloon." % [dialogue_balloon_path])
3030
dialogue_balloon_path = ParleySettings.DEFAULT_SETTINGS[ParleyConstants.DIALOGUE_BALLOON_PATH]
3131
var dialogue_balloon_scene: PackedScene = load(dialogue_balloon_path)
3232
var balloon: Node = dialogue_balloon_scene.instantiate()
3333
current_scene.add_child(balloon)
34-
if not dialogue_ast:
34+
if not dialogue_sequence_ast:
3535
ParleyUtils.log.error("No active Dialogue AST set, exiting.")
3636
return balloon
3737
if balloon.has_method(&"start"):
3838
@warning_ignore("UNSAFE_METHOD_ACCESS") # Covered by the if statement
39-
balloon.start(ctx, dialogue_ast, start_node)
39+
balloon.start(ctx, dialogue_sequence_ast, start_node)
4040
else:
4141
# TODO: add translation for error here
4242
assert(false, "Dialogue balloon is missing the `start` method can cannot execute the Dialogue Sequence")
4343
return balloon
4444

45-
func get_current_scene() -> Node:
45+
func _get_current_scene() -> Node:
4646
@warning_ignore("UNSAFE_PROPERTY_ACCESS")
4747
var current_scene: Node = Engine.get_main_loop().current_scene
4848
if current_scene == null:

docs/latest/concepts/architecture.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ in Parley is at its core a Node. These can be defined and combined countless
4242
times within a Dialogue Sequence to create highly intricate behaviours and
4343
gameplay. The sky is the limit for how these can be combined!
4444

45+
For information about Nodes can be found [here](../nodes/index.md).
46+
4547
## Edge
4648

4749
A connection between two nodes. They have a direction defined by two attributes:
Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,49 @@
11
---
22
description: |
3-
Parley Runtime: TODO
3+
Parley provides a runtime instance that the developer can use to run Dialogue Sequences when the game is running.
44
---
55

6-
Parley Runtime: TODO
6+
Parley provides a runtime instance that the developer can use to run Dialogue
7+
Sequences when the game is running. This is autoloaded as `Parley` upon
8+
activation of the Parley plugin. It can be used to:
9+
10+
- [Start Dialogue Sequences.](#starting-a-dialogue-sequence)
11+
12+
## Starting a Dialogue Sequence
13+
14+
A Dialogue Sequence can be started using the Parley runtime as follows:
15+
16+
```gdscript
17+
extends Node
18+
19+
const basic_dialogue: ParleyDialogueSequenceAst = preload("res://dialogue_sequences/my_dialogue.ds")
20+
21+
func _ready() -> void:
22+
# Trigger the start of the Dialogue Sequence processing using the Parley autoload
23+
var _result: Node = Parley.start_dialogue({}, basic_dialogue)
24+
```
25+
26+
For a real example of starting a Dialogue Sequence, please see this
27+
[guide](../getting-started/run-dialogue-sequence.md).
28+
29+
## Reference
30+
31+
### `start_dialogue`
32+
33+
`start_dialogue(ctx: Dictionary, dialogue_sequence_ast: ParleyDialogueSequenceAst, start_node: ParleyNodeAst = null) -> Node`
34+
35+
Parameters:
36+
37+
- **ctx** `Dictionary` - This is the current context object of the Dialogue
38+
Sequence. It is passed from Node to Node and can be used to hold non-global
39+
state that the Nodes can get access to.
40+
- **dialogue_sequence_ast** `ParleyDialogueSequenceAst` - This is the Dialogue
41+
Sequence instance to process.
42+
- **start_node** `ParleyNodeAst` - Default: `null` - This is the the Node to
43+
start the Dialogue Sequence from. This is useful when resuming an already
44+
started Dialogue Sequence. For example, loading a save game. If not defined,
45+
Parley will attempt to find the Start Node.
46+
47+
Returns the instantiated Dialogue Balloon that has been used to render the
48+
running Dialogue Sequence. This can be controlled via the
49+
[Parley settings](../reference/parley-settings.md).

docs/toc.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import PARLEY_VERSIONS from "../versions.json" with { type: "json" };
44

5+
// Adapted from: https://github.com/denoland/fresh
6+
57
type RawTableOfContents = Record<
68
string,
79
{

scripts/check_licence.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
import { walk } from "jsr:@std/fs/walk";
66
import { globToRegExp } from "jsr:@std/path/glob-to-regexp";
77

8-
const EXTENSIONS: [string, string][] = [
9-
[".ts", "//"],
10-
[".gd", "#"],
8+
const EXTENSIONS: [string, string, string][] = [
9+
[".ts", "//", ""],
10+
[".tsx", "//", ""],
11+
[".css", "/*", " */"],
12+
[".gd", "#", ""],
1113
];
1214
const EXCLUDED_DIRS = [
1315
"**/.godot",
16+
"**/_fresh",
1417
"**/addons/gut",
1518
];
1619

@@ -19,7 +22,7 @@ const CHECK = Deno.args.includes("--check");
1922
const FIRST_YEAR = 2024;
2023
const CURRENT_YEAR = new Date().getFullYear();
2124
const RX_COPYRIGHT = new RegExp(
22-
"Copyright ([0-9]{4})-([0-9]{4}) the Bisterix Studio authors\\. All rights reserved\\. MIT license\\.\n",
25+
"Copyright ([0-9]{4})-([0-9]{4}) the Bisterix Studio authors\\. All rights reserved\\. MIT license\\.",
2326
);
2427
const COPYRIGHT =
2528
`Copyright ${FIRST_YEAR}-${CURRENT_YEAR} the Bisterix Studio authors. All rights reserved. MIT license.`;
@@ -41,12 +44,14 @@ for await (
4144
console.error(`Missing copyright header: ${path}`);
4245
failed = true;
4346
} else {
44-
const prefix = EXTENSIONS.find((ext) => path.endsWith(ext[0]))?.[1];
45-
if (!prefix) {
46-
console.error(`Unable to find comment prefix for path: ${path}`);
47+
const extension = EXTENSIONS.find((ext) => path.endsWith(ext[0]));
48+
if (!extension) {
49+
console.error(`Unable to find extension for path: ${path}`);
4750
failed = true;
4851
} else {
49-
const contentWithCopyright = prefix + " " + COPYRIGHT + "\n\n" +
52+
const [, prefix, suffix] = extension;
53+
const contentWithCopyright = prefix + " " + COPYRIGHT + suffix +
54+
"\n\n" +
5055
content;
5156
await Deno.writeTextFile(path, contentWithCopyright);
5257
console.log("Copyright header automatically added to " + path);

0 commit comments

Comments
 (0)