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 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, stop: 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 = path.resolve(runGit(['rev-parse', '--show-toplevel'], repoDir))
51
- const dir = path.resolve(repoDir)
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 root = path.resolve(runGit(['rev-parse', '--show-toplevel'], repoDir))
82
- const dir = path.resolve(repoDir)
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 = path.resolve(runGit(['rev-parse', '--show-toplevel'], repoDir))
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-'))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalk-automation-plugin",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Home Assistant-like YAML automations for Signal K",
5
5
  "main": "plugin/index.js",
6
6
  "keywords": [