signalk-automation-plugin 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/engine.js +1 -1
- package/lib/git.js +14 -10
- package/package.json +1 -1
package/lib/engine.js
CHANGED
|
@@ -579,7 +579,7 @@ async function runAction (action, ctx) {
|
|
|
579
579
|
}
|
|
580
580
|
if (action.delay != null) {
|
|
581
581
|
const ms = parseDuration(action.delay)
|
|
582
|
-
if (ctx.skipDelay) return { ok: true, type: 'delay', ms, skipped: true
|
|
582
|
+
if (ctx.skipDelay) return { ok: true, type: 'delay', ms, skipped: true }
|
|
583
583
|
try {
|
|
584
584
|
await ctx.sleep(ms)
|
|
585
585
|
} catch (err) {
|
package/lib/git.js
CHANGED
|
@@ -46,9 +46,18 @@ function currentSha (dir) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
function canonicalPath (p) {
|
|
50
|
+
const resolved = path.resolve(p)
|
|
51
|
+
try {
|
|
52
|
+
return fs.realpathSync(resolved)
|
|
53
|
+
} catch (_) {
|
|
54
|
+
return resolved
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
function repoRelPath (repoDir) {
|
|
50
|
-
const root =
|
|
51
|
-
const dir =
|
|
59
|
+
const root = canonicalPath(runGit(['rev-parse', '--show-toplevel'], repoDir))
|
|
60
|
+
const dir = canonicalPath(repoDir)
|
|
52
61
|
const rel = path.relative(root, dir).replace(/\\/g, '/')
|
|
53
62
|
if (!rel || rel === '.') return { root, rel: '' }
|
|
54
63
|
if (rel.startsWith('..') || path.isAbsolute(rel)) {
|
|
@@ -78,13 +87,8 @@ function diffRange (repoDir, fromSha, toSha) {
|
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
function archiveTreeish (repoDir, sha) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const rel = path.relative(root, dir).replace(/\\/g, '/')
|
|
84
|
-
if (!rel || rel === '.') return sha
|
|
85
|
-
if (rel.startsWith('..') || path.isAbsolute(rel)) {
|
|
86
|
-
throw new Error('automationsDir is outside the git repository')
|
|
87
|
-
}
|
|
90
|
+
const { rel } = repoRelPath(repoDir)
|
|
91
|
+
if (!rel) return sha
|
|
88
92
|
return sha + ':' + rel
|
|
89
93
|
}
|
|
90
94
|
|
|
@@ -93,7 +97,7 @@ function materializeCommit (repoDir, sha, destDir) {
|
|
|
93
97
|
if (!isGitRepo(repoDir)) throw new Error('automationsDir is not a git repository')
|
|
94
98
|
runGit(['cat-file', '-t', sha], repoDir)
|
|
95
99
|
const treeish = archiveTreeish(repoDir, sha)
|
|
96
|
-
const root =
|
|
100
|
+
const root = repoRelPath(repoDir).root
|
|
97
101
|
const parent = path.dirname(path.resolve(destDir))
|
|
98
102
|
fs.mkdirSync(parent, { recursive: true })
|
|
99
103
|
const tmp = fs.mkdtempSync(path.join(parent, 'live-tmp-'))
|