Skip to content

Commit c0e153c

Browse files
committed
Add header-comment as an option
1 parent 2358f50 commit c0e153c

File tree

5 files changed

+40
-24
lines changed

5 files changed

+40
-24
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ fine!) will default to these values that should work fine for most people.
7171
;; the plugin itself and checking that it's running when you expect it to.
7272
:verbose false
7373
74+
;; When false, will not write the protective `-- [nfnl] Compiled from ...` header to the resulting .lua files.
75+
;; It will also prevent nfnl from checking for this header before overwriting .lua files.
76+
;; Intended for users who wish to write shebang comments at the top of their .lua for easier execution.
77+
:header-comment true
78+
7479
;; Passed to fennel.compileString when your code is compiled.
7580
;; See https://fennel-lang.org/api for more information.
7681
:compiler-options {;; Disables ansi escape sequences in compiler output.

fnl/nfnl/compile.fnl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@
7373
(notify.info "Successfully compiled: " path))
7474
{:status :ok
7575
:source-path path
76-
:result (.. (with-header rel-file-name res) "\n")})
76+
:result (.. (if (cfg [:header-comment])
77+
(with-header rel-file-name res)
78+
res)
79+
"\n")})
7780
(do
7881
(when (not batch?)
7982
(notify.error res))
@@ -90,7 +93,8 @@
9093
(not= :ok status)
9194
res
9295

93-
(safe-target? destination-path)
96+
(or (safe-target? destination-path)
97+
(not (cfg [:header-comment])))
9498
(do
9599
(fs.mkdirp (fs.basename destination-path))
96100
(core.spit destination-path result)

fnl/nfnl/config.fnl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
:base-dirs [root-dir]})]
6464

6565
{:verbose false
66+
:header-comment true
6667
:compiler-options {:error-pinpoint false}
6768

6869
:root-dir root-dir

lua/nfnl/compile.lua

Lines changed: 27 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lua/nfnl/config.lua

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)