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

Commit 3eaee98

Browse files
committed
add packer:export
1 parent 8e69330 commit 3eaee98

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Added `include_entry` option
13+
- Added `packer:export()`
1314

1415
### Changed
1516

1617
- Improved CLI option handler
18+
- `packer:pack()` no longer returns the full lua, use `packer:export()` to get it
1719

1820
## [0.4.1] - 2022-04-12
1921

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ local packer = luapack.Packer()
3131
-- or with options:
3232
-- local packer = luapack.Packer({minify = false})
3333

34-
local packed = packer:pack("test.lua")
35-
print(packed)
34+
packer:pack("test.lua")
35+
print(packer:export())
3636
```
3737

3838
Make a new packer instance for each file you want to pack!
@@ -93,8 +93,8 @@ local packer = luapack.Packer()
9393

9494
packer:include("dependency")
9595

96-
local packed = packer:pack("test.lua")
97-
print(packed)
96+
packer:pack("test.lua")
97+
print(packed:export())
9898
```
9999

100100
Output:
@@ -121,8 +121,8 @@ end
121121
-- package_polyfill to create package and require
122122
local packer = luapack.Packer({package_polyfill = true})
123123

124-
local packed = packer:pack("test.lua")
125-
print(packed)
124+
packer:pack("test.lua")
125+
print(packed:export())
126126
```
127127

128128
Or use the `-yes-package-polyfill` CLI option.
@@ -195,7 +195,9 @@ Includes the package and its dependencies.
195195

196196
Includes the file as entry.
197197

198-
Minifies and adds the luapack header.
198+
- **luapack:export()**
199+
200+
Returns the bootstrapped lua code, with header and minification.
199201

200202
- **luapack:bootstrap()**
201203

@@ -256,8 +258,8 @@ luapack.helpers.fast_push(luapack.default_plugins, {
256258
})
257259

258260
local packer = luapack.Packer()
259-
local packed = packer:pack("test.lua")
260-
print(packed)
261+
packer:pack("test.lua")
262+
print(packed:export())
261263
```
262264

263265
Output:

luapack.yue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export class Packer
154154

155155
@loaded["__luapack_entry__"] = nil if @options.include_entry == false
156156

157+
@export: =>
157158
packed = @bootstrap!
158159
packed = minifier.Rebuild.MinifyString packed if @options.minify != false and "table" == type minifier
159160
header = ""
@@ -236,7 +237,8 @@ cli = (arguments) ->
236237
continue if "-" == filename::sub 1, 1
237238
print "Packing #{filename}"
238239
packer = Packer options
239-
packed = packer::pack filename
240+
packer::pack filename
241+
packed = packer::export!
240242
outfile = filename::gsub "%.(%a+)$", (x) -> ".packed.lua"
241243
print "Packed into #{outfile}"
242244
break if filename == outfile

0 commit comments

Comments
 (0)