Skip to content

Commit 47af8b0

Browse files
committed
Fix
1 parent 077cc27 commit 47af8b0

3 files changed

Lines changed: 34 additions & 26 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ jobs:
4545
# luac only proves a file parses; this proves the engine comes up.
4646
- name: Smoke-test the source install
4747
run: |
48-
mkdir -p "$RUNNER_TEMP/craftos-smoke"
49-
cp tools/smoketest.lua "$RUNNER_TEMP/craftos-smoke/smoketest.lua"
48+
# --directory is CraftOS-PC's *data* directory; the computer's own
49+
# root lives in computer/0 below it. Files copied anywhere else are
50+
# invisible to the shell.
51+
root="$RUNNER_TEMP/craftos-smoke/computer/0"
52+
mkdir -p "$root"
53+
cp tools/smoketest.lua "$root/smoketest.lua"
5054
craftos \
5155
--headless \
5256
--directory "$RUNNER_TEMP/craftos-smoke" \
@@ -87,14 +91,15 @@ jobs:
8791
- name: Smoke-test release bundles
8892
run: |
8993
for variant in obsidian obsidian.min obsidian.compressed; do
90-
workdir="$RUNNER_TEMP/craftos-bundle-$variant"
91-
mkdir -p "$workdir"
92-
cp tools/smoketest.lua "$workdir/smoketest.lua"
93-
cp "$RUNNER_TEMP/obsidian-bundle/$variant.lua" "$workdir/obsidian.lua"
94+
datadir="$RUNNER_TEMP/craftos-bundle-$variant"
95+
root="$datadir/computer/0"
96+
mkdir -p "$root"
97+
cp tools/smoketest.lua "$root/smoketest.lua"
98+
cp "$RUNNER_TEMP/obsidian-bundle/$variant.lua" "$root/obsidian.lua"
9499
echo "--- $variant.lua ---"
95100
craftos \
96101
--headless \
97-
--directory "$workdir" \
102+
--directory "$datadir" \
98103
--exec "local ok = shell.run('smoketest.lua'); os.shutdown(ok and 0 or 1)"
99104
done
100105

‎.github/workflows/docs.yml‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
name: Obsidian Docs & Deploy
22

3+
# Manual only. Publishing to Pages is never triggered by a push; run this
4+
# workflow from the Actions tab when the site should be updated.
35
on:
4-
push:
5-
branches:
6-
- master
7-
paths:
8-
- 'src/**'
9-
- 'guides/**'
10-
- 'tools/docgen.lua'
11-
- '.github/vitepress.config.mts'
12-
- '.github/docs-index.md'
13-
- '.github/docs-home.md'
14-
- '.github/workflows/docs.yml'
156
workflow_dispatch:
167

178
permissions:

‎src/init.lua‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,31 @@
1919

2020
local args = { ... }
2121

22-
--- Obsidian's own directory. CraftOS' require calls a module chunk with
23-
--- (name, path); running this file as a program is supported as a fallback.
22+
--- Obsidian's own directory.
23+
---
24+
--- Asking the chunk where it was loaded from is the only method that does not
25+
--- depend on how the caller invoked it: a module is compiled with the chunk
26+
--- name "@/path/to/init.lua". The (name, path) pair that CraftOS' require
27+
--- passes is kept as a fallback for hosts without debug.getinfo.
28+
---
29+
--- Deliberately no fallback to shell.getRunningProgram(): that yields the
30+
--- directory of the *calling* program, which would silently resolve modules
31+
--- against the wrong tree instead of failing.
2432
local function locate()
33+
local getinfo = _G.debug and _G.debug.getinfo
34+
if getinfo then
35+
local info = getinfo(1, "S")
36+
local source = info and info.source
37+
if type(source) == "string" and source:sub(1, 1) == "@" then
38+
return fs.getDir(source:sub(2))
39+
end
40+
end
41+
2542
local path = args[2]
2643
if type(path) == "string" and path ~= "" then
2744
return fs.getDir(path)
2845
end
29-
if shell and shell.getRunningProgram then
30-
local running = shell.getRunningProgram()
31-
if type(running) == "string" and running ~= "" then
32-
return fs.getDir(running)
33-
end
34-
end
46+
3547
error("Obsidian: cannot determine its own location. "
3648
.. 'Load it with require("obsidian").', 0)
3749
end

0 commit comments

Comments
 (0)