|
| 1 | +-- fileExists: true if the file at `name` exists |
| 2 | +-- from https://pandoc.org/lua-filters.html#building-images-with-tikz |
| 3 | +local function fileExists(name) |
| 4 | + local f = io.open(name, 'r') |
| 5 | + if f ~= nil then |
| 6 | + io.close(f) |
| 7 | + return true |
| 8 | + else |
| 9 | + return false |
| 10 | + end |
| 11 | +end |
| 12 | + |
| 13 | +-- getRollupConfig: return the path to the rollup config file |
| 14 | +local function getRollupConfig() |
| 15 | + if fileExists("./_extensions/jimjam-slam/sverto/rollup.config.js") then |
| 16 | + return "./_extensions/jimjam-slam/sverto/rollup.config.js" |
| 17 | + elseif fileExists("./_extensions/sverto/rollup.config.js") then |
| 18 | + return "./_extensions/sverto/rollup.config.js" |
| 19 | + else |
| 20 | + print("Error: no rollup config found. Is Sverto installed properly?") |
| 21 | + os.exit(1) |
| 22 | + end |
| 23 | +end |
1 | 24 |
|
2 | 25 | -- return contents of named file
|
3 | 26 | function read_file(name)
|
|
30 | 53 | -- end
|
31 | 54 | -- end
|
32 | 55 |
|
33 |
| --- file_exists: true if the file at `name` exists |
34 |
| --- from https://pandoc.org/lua-filters.html#building-images-with-tikz |
35 |
| -function file_exists(name) |
36 |
| - local f = io.open(name, 'r') |
37 |
| - if f ~= nil then |
38 |
| - io.close(f) |
39 |
| - return true |
40 |
| - else |
41 |
| - return false |
42 |
| - end |
43 |
| -end |
44 |
| - |
45 | 56 | -- offset a relative `svelte_path` to a .qmd `input_path`, or an absolute
|
46 | 57 | -- `svelte_path` to the project path. then normalize.
|
47 | 58 | function offset_svelte_path(svelte_path, input_path)
|
@@ -119,20 +130,10 @@ for _, svelte_path in pairs(svelte_paths) do
|
119 | 130 | end
|
120 | 131 |
|
121 | 132 | -- finally, call the svelte compiler via rollup
|
122 |
| -rollup_config = "" |
123 |
| -if file_exists("./_extensions/jimjam-slam/sverto/rollup.config.js") then |
124 |
| - rollup_config = "./_extensions/jimjam-slam/sverto/rollup.config.js" |
125 |
| -elseif file_exists("./_extensions/sverto/rollup.config.js") then |
126 |
| - rollup_config = "./_extensions/sverto/rollup.config.js" |
127 |
| -else |
128 |
| - print("Error: no rollup config found. Is Sverto installed properly?") |
129 |
| - os.exit(1) |
130 |
| -end |
131 |
| - |
132 | 133 | cmd =
|
133 | 134 | get_cmd_prefix() ..
|
134 | 135 | "npm run build " ..
|
135 |
| - rollup_config .. " -- " .. |
| 136 | + getRollupConfig() .. " -- " .. |
136 | 137 | '--configQuartoOutPath="' .. os.getenv("QUARTO_PROJECT_OUTPUT_DIR") .. '" ' ..
|
137 | 138 | '--configSvelteInPaths="' .. svelte_path_string .. '"'
|
138 | 139 |
|
|
0 commit comments