Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit 5e0dc15

Browse files
committed
fix cli and optional dependencies
1 parent 42d8784 commit 5e0dc15

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- require of package polyfill now calls the preload function with correct arguments
1313

14+
### Fixed
15+
16+
- Fixed CLI (finally)
17+
- Fixed optional dependecies not being optional
18+
1419
## [0.3.0] - 2022-02-04
1520

1621
### Added

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Head to [releases](https://github.com/Le0Developer/luapack/releases) and get the
1212

1313
Install [yuescript](http://yuescript.org): `luarocks install yuescript`
1414

15-
And then run `yue -e luapack.yue luapack.yue`.
15+
And then run `yue -e luapack.yue` followed by `lua luapack.lua luapack.lua`.
1616

17-
You can use `luapack.luapacked.lua` afterwards.
17+
You can use `luapack.packed.lua` afterwards.
1818

1919
## Usage
2020

luapack.yue

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fast_push default_plugins,
8181
name: "lua"
8282
searchpath: (packer, name) -> searchpath_compat name, package.path
8383

84-
if yue
84+
if "table" == type yue
8585
fast_push default_plugins,
8686
name: "yuescript"
8787
searchpath: (packer, name) -> searchpath_compat name, package_path_with_different_extension "yue"
@@ -90,7 +90,7 @@ if yue
9090
lua = yue.to_lua content, reserve_line_number: false
9191
lua, replace_file_extension filename, ".yue", ".lua"
9292

93-
if moon
93+
if "table" == type moon
9494
fast_push default_plugins,
9595
name: "moonscript"
9696
searchpath: (packer, name) -> searchpath_compat name, package_path_with_different_extension "moon"
@@ -151,7 +151,7 @@ export class Packer
151151
error "file not found: #{entry}" unless @loaded["__luapack_entry__"]?
152152

153153
packed = @bootstrap!
154-
packed = minifier.Rebuild.MinifyString packed if @options.minify != false and minifier
154+
packed = minifier.Rebuild.MinifyString packed if @options.minify != false and "table" == type minifier
155155
header = ""
156156
if @options.with_header != false
157157
header = "-- luapacked using #{__version__}\n"
@@ -205,12 +205,7 @@ export class Packer
205205
writer\str!
206206

207207
-- cli
208-
arguments = {...}
209-
arguments.n = #arguments
210-
211-
-- "clever" cli detection
212-
if arguments.n > 0 and arguments[2] != ":preload:" and not package.loaded[arguments[1]]?
213-
-- user is using cli!
208+
cli = (arguments) ->
214209
options = {}
215210
for arg in *arguments
216211
continue if "-" != arg\sub 1, 1
@@ -235,3 +230,21 @@ if arguments.n > 0 and arguments[2] != ":preload:" and not package.loaded[argume
235230
with io.open outfile, "w"
236231
\write packed
237232
\close!
233+
234+
235+
check_cli = =>
236+
return if @n == 0
237+
return if @[2] == ":preload:" -- package.preload (luapacked)
238+
return unless arg? -- support for cli args
239+
240+
-- check if they match
241+
for i = 1, @n
242+
return if arg[i] != @[i] -- dont match
243+
244+
true
245+
246+
247+
arguments = {...}
248+
arguments.n = #arguments
249+
250+
cli arguments if check_cli arguments

0 commit comments

Comments
 (0)