@ds-sfdc/sfparty 1.3.9 → 1.3.10

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.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ds-sfdc/sfparty",
3
- "version": "1.3.9",
3
+ "version": "1.3.10",
4
4
  "description": "Salesforce metadata XML splitter for CI/CD",
5
5
  "type": "module",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict'
3
- import { spawnSync } from 'child_process'
4
- import { readFileSync } from 'fs'
3
+ import { spawnSync, spawn, execSync } from 'child_process'
4
+ import fs from 'fs'
5
5
  import path from 'path'
6
6
  import yargs from 'yargs'
7
7
  import { hideBin } from 'yargs/helpers'
@@ -66,8 +66,8 @@ const typeArray = ['label', 'profile', 'permset', 'workflow']
66
66
 
67
67
  global.git = {
68
68
  enabled: false,
69
- last: undefined,
70
- latest: undefined,
69
+ lastCommit: undefined,
70
+ latestCommit: undefined,
71
71
  append: false,
72
72
  delta: false,
73
73
  }
@@ -104,10 +104,10 @@ const packageDir = getRootPath()
104
104
 
105
105
  let errorMessage = clc.red(
106
106
  'Please specify the action of ' +
107
- clc.whiteBright.bgRedBright('split') +
108
- ' or ' +
109
- clc.whiteBright.bgRedBright('combine') +
110
- '.',
107
+ clc.whiteBright.bgRedBright('split') +
108
+ ' or ' +
109
+ clc.whiteBright.bgRedBright('combine') +
110
+ '.',
111
111
  )
112
112
 
113
113
  displayHeader() // display header mast
@@ -117,7 +117,7 @@ yargs(hideBin(process.argv))
117
117
  command: 'help',
118
118
  alias: 'h',
119
119
  handler: (argv) => {
120
- const data = readFileSync(
120
+ const data = fs.readFileSync(
121
121
  path.join(process.cwd(), 'README.md'),
122
122
  'utf8',
123
123
  )
@@ -193,12 +193,17 @@ yargs(hideBin(process.argv))
193
193
  global.git.append = argv.append || global.git.append
194
194
  global.git.delta = argv.delta || global.git.delta
195
195
  if (argv.git === '') {
196
- const commit = git.lastCommit(global.__basedir, '-1')
196
+ const commit = git.lastCommit({
197
+ dir: global.__basedir,
198
+ existsSync: fs.existsSync,
199
+ execSync,
200
+ fileUtils,
201
+ })
197
202
  commit
198
203
  .then((data, error) => {
199
- global.git.latest = data.latestCommit
200
- global.git.last = data.lastCommit
201
- if (data.last === undefined) {
204
+ global.git.latestCommit = data.latestCommit
205
+ global.git.lastCommit = data.lastCommit
206
+ if (data.lastCommit === undefined) {
202
207
  gitMode({ status: 'not active' })
203
208
  resolve(false)
204
209
  } else {
@@ -207,10 +212,12 @@ yargs(hideBin(process.argv))
207
212
  lastCommit: data.lastCommit,
208
213
  latestCommit: data.latestCommit,
209
214
  })
210
- const diff = git.diff(
211
- global.__basedir,
212
- `${data.lastCommit}..${data.latestCommit}`,
213
- )
215
+ const diff = git.diff({
216
+ dir: global.__basedir,
217
+ gitRef: `${data.lastCommit}..${data.latestCommit}`,
218
+ existsSync: fs.existsSync,
219
+ spawn,
220
+ })
214
221
  diff.then((data, error) => {
215
222
  gitFiles(data)
216
223
  resolve(true)
@@ -226,7 +233,12 @@ yargs(hideBin(process.argv))
226
233
  })
227
234
  } else {
228
235
  gitMode({ status: 'active', gitRef })
229
- const diff = git.diff(global.__basedir, gitRef)
236
+ const diff = git.diff({
237
+ dir: global.__basedir,
238
+ gitRef,
239
+ existsSync: fs.existsSync,
240
+ spawn,
241
+ })
230
242
  diff.then((data, error) => {
231
243
  gitFiles(data)
232
244
  resolve(true)
@@ -266,10 +278,11 @@ function gitMode({ status, gitRef, lastCommit, latestCommit }) {
266
278
  } else {
267
279
  statusMessage = clc.magentaBright('active:')
268
280
  if (gitRef === undefined) {
269
- displayMessage = `${clc.bgBlackBright(lastCommit) +
281
+ displayMessage = `${
282
+ clc.bgBlackBright(lastCommit) +
270
283
  '..' +
271
284
  clc.bgBlackBright(latestCommit)
272
- }`
285
+ }`
273
286
  } else {
274
287
  let delimiter = '..'
275
288
 
@@ -331,8 +344,8 @@ function yargCheck(argv, options) {
331
344
  throw new Error(
332
345
  clc.redBright(
333
346
  'You cannot specify ' +
334
- clc.whiteBright.bgRedBright('--name') +
335
- ' when using multiple types.',
347
+ clc.whiteBright.bgRedBright('--name') +
348
+ ' when using multiple types.',
336
349
  ),
337
350
  )
338
351
  }
@@ -343,8 +356,8 @@ function yargCheck(argv, options) {
343
356
  throw new Error(
344
357
  clc.redBright(
345
358
  'You cannot specify ' +
346
- clc.whiteBright.bgRedBright('--name') +
347
- ' when using label.',
359
+ clc.whiteBright.bgRedBright('--name') +
360
+ ' when using label.',
348
361
  ),
349
362
  )
350
363
  }
@@ -361,12 +374,12 @@ function displayMessageAndDuration(startTime, message) {
361
374
  let minutes = Math.floor(
362
375
  (executionTime.seconds +
363
376
  Math.round(executionTime.milliseconds / 100000)) /
364
- 60,
377
+ 60,
365
378
  )
366
379
  let seconds = Math.round(
367
380
  (executionTime.seconds +
368
381
  Math.round(executionTime.milliseconds / 100000)) %
369
- 60,
382
+ 60,
370
383
  )
371
384
  if (minutes == 0 && seconds == 0) {
372
385
  durationMessage = message + clc.magentaBright(`<1s`)
@@ -459,17 +472,17 @@ function processSplit(typeItem, argv) {
459
472
 
460
473
  if (!all) {
461
474
  let metaFilePath = path.join(metaDirPath, name)
462
- if (!fileUtils.fileExists(metaFilePath)) {
475
+ if (!fileUtils.fileExists({ filePath: metaFilePath, fs })) {
463
476
  name += metaExtension
464
477
  metaFilePath = path.join(metaDirPath, name)
465
- if (!fileUtils.fileExists(metaFilePath)) {
478
+ if (!fileUtils.fileExists({ filePath: metaFilePath, fs })) {
466
479
  global.logger.error('File not found: ' + metaFilePath)
467
480
  process.exit(1)
468
481
  }
469
482
  }
470
483
  fileList.push(name)
471
484
  } else {
472
- if (fileUtils.directoryExists(sourceDir)) {
485
+ if (fileUtils.directoryExists({ dirPath: sourceDir, fs })) {
473
486
  fileUtils.getFiles(sourceDir, metaExtension).forEach((file) => {
474
487
  fileList.push(file)
475
488
  })
@@ -512,12 +525,13 @@ function processSplit(typeItem, argv) {
512
525
  processed.current > promList.length
513
526
  ? promList.length
514
527
  : processed.current,
515
- )} file(s) ${processed.errors > 0
528
+ )} file(s) ${
529
+ processed.errors > 0
516
530
  ? 'with ' +
517
- clc.bgBlackBright.red(processed.errors) +
518
- ' error(s) '
531
+ clc.bgBlackBright.red(processed.errors) +
532
+ ' error(s) '
519
533
  : ''
520
- }in `
534
+ }in `
521
535
  displayMessageAndDuration(startTime, message)
522
536
  resolve(true)
523
537
  })
@@ -532,8 +546,13 @@ function combineHandler(argv, startTime) {
532
546
  console.log()
533
547
  combineHandler(argv, startTime)
534
548
  } else {
535
- if (global.git.latest !== undefined) {
536
- git.updateLastCommit(global.__basedir, global.git.latest)
549
+ if (global.git.latestCommit !== undefined) {
550
+ git.updateLastCommit({
551
+ dir: global.__basedir,
552
+ latest: global.git.latestCommit,
553
+ fileUtils,
554
+ fs,
555
+ })
537
556
  }
538
557
  if (argv.type === undefined || argv.type.split(',').length > 1) {
539
558
  let message = `Split completed in `
@@ -610,7 +629,7 @@ function processCombine(typeItem, argv) {
610
629
  }
611
630
  } else if (!all) {
612
631
  let metaDirPath = path.join(sourceDir, name)
613
- if (!fileUtils.directoryExists(metaDirPath)) {
632
+ if (!fileUtils.directoryExists({ dirPath: metaDirPath, fs })) {
614
633
  global.logger.error('Directory not found: ' + metaDirPath)
615
634
  process.exit(1)
616
635
  }
@@ -675,10 +694,11 @@ function processCombine(typeItem, argv) {
675
694
  errors++
676
695
  }
677
696
  })
678
- let message = `Combined ${clc.bgBlackBright(successes)} file(s) ${errors > 0
697
+ let message = `Combined ${clc.bgBlackBright(successes)} file(s) ${
698
+ errors > 0
679
699
  ? 'with ' + clc.bgBlackBright(errors) + 'error(s) '
680
700
  : ''
681
- }in `
701
+ }in `
682
702
  displayMessageAndDuration(startTime, message)
683
703
  resolve(true)
684
704
  })
@@ -762,10 +782,11 @@ function displayHeader() {
762
782
  horizontal: '─',
763
783
  vertical: '│',
764
784
  }
765
- let versionString = `sfparty v${pkgObj.version}${process.stdout.columns > pkgObj.description.length + 15
785
+ let versionString = `sfparty v${pkgObj.version}${
786
+ process.stdout.columns > pkgObj.description.length + 15
766
787
  ? ' - ' + pkgObj.description
767
788
  : ''
768
- }`
789
+ }`
769
790
  let titleMessage = `${global.icons.party} ${clc.yellowBright(
770
791
  versionString,
771
792
  )} ${global.icons.party}`
@@ -782,16 +803,16 @@ function displayHeader() {
782
803
  console.log(
783
804
  `${clc.blackBright(
784
805
  box.topLeft +
785
- box.horizontal.repeat(process.stdout.columns - 2) +
786
- box.topRight,
806
+ box.horizontal.repeat(process.stdout.columns - 2) +
807
+ box.topRight,
787
808
  )}`,
788
809
  )
789
810
  console.log(titleMessage)
790
811
  console.log(
791
812
  `${clc.blackBright(
792
813
  box.bottomLeft +
793
- box.horizontal.repeat(process.stdout.columns - 2) +
794
- box.bottomRight,
814
+ box.horizontal.repeat(process.stdout.columns - 2) +
815
+ box.bottomRight,
795
816
  )}`,
796
817
  )
797
818
  console.log()
@@ -802,9 +823,9 @@ function getRootPath(packageDir) {
802
823
  let defaultDir
803
824
  if (rootPath) {
804
825
  global.__basedir = fileUtils.fileInfo(rootPath).dirname
805
- let packageJSON
826
+ let projectJSON
806
827
  try {
807
- packageJSON = JSON.parse(readFileSync(rootPath))
828
+ projectJSON = JSON.parse(fs.readFileSync(rootPath))
808
829
  } catch (error) {
809
830
  if (error.message.indexOf('JSON at position') > 0) {
810
831
  global.displayError('sfdx-project.json has invalid JSON', true)
@@ -812,11 +833,11 @@ function getRootPath(packageDir) {
812
833
  global.displayError(error, true)
813
834
  }
814
835
  }
815
- if (Array.isArray(packageJSON.packageDirectories)) {
816
- packageJSON.packageDirectories.every((directory) => {
836
+ if (Array.isArray(projectJSON.packageDirectories)) {
837
+ projectJSON.packageDirectories.every((directory) => {
817
838
  if (
818
839
  directory.default ||
819
- packageJSON.packageDirectories.length == 1
840
+ projectJSON.packageDirectories.length == 1
820
841
  )
821
842
  defaultDir = directory.path
822
843
  if (directory == packageDir) {
@@ -39,7 +39,7 @@ export async function checkVersion({
39
39
  )
40
40
  const latestVersion = data['dist-tags'].latest
41
41
  if (semver.gt(latestVersion, currentVersion)) {
42
- const version = clc.bgCyanBright(data['dist-tags'].latest)
42
+ const version = clc.bgMagenta(data['dist-tags'].latest)
43
43
  const icon = update ? global.icons.working : global.icons.fail
44
44
  console.log()
45
45
  console.log(`${icon} A newer version ${version} is available.`)
@@ -4,12 +4,12 @@ import * as path from 'path'
4
4
  import * as yaml from 'js-yaml'
5
5
  import { Parser } from 'xml2js'
6
6
 
7
- export function directoryExists(dirPath, fsTmp = fs) {
8
- return fsTmp.existsSync(dirPath) && fsTmp.statSync(dirPath).isDirectory()
7
+ export function directoryExists({ dirPath, fs }) {
8
+ return fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory()
9
9
  }
10
10
 
11
- export function fileExists(filePath, fsTmp = fs) {
12
- return fsTmp.existsSync(filePath) && fsTmp.statSync(filePath).isFile()
11
+ export function fileExists({ filePath, fs }) {
12
+ return fs.existsSync(filePath) && fs.statSync(filePath).isFile()
13
13
  }
14
14
 
15
15
  export function createDirectory(dirPath, fsTmp = fs) {
@@ -19,7 +19,7 @@ export function createDirectory(dirPath, fsTmp = fs) {
19
19
  }
20
20
 
21
21
  export function deleteDirectory(dirPath, recursive = false, fsTmp = fs) {
22
- if (!directoryExists(dirPath, fsTmp)) {
22
+ if (!directoryExists({ dirPath, fs: fsTmp })) {
23
23
  return false
24
24
  } else {
25
25
  if (fsTmp.existsSync(dirPath)) {
@@ -40,7 +40,7 @@ export function deleteDirectory(dirPath, recursive = false, fsTmp = fs) {
40
40
 
41
41
  export function getFiles(dirPath, filter = undefined, fsTmp = fs) {
42
42
  const filesList = []
43
- if (directoryExists(dirPath, fsTmp)) {
43
+ if (directoryExists({ dirPath, fs: fsTmp })) {
44
44
  fsTmp.readdirSync(dirPath).forEach((file) => {
45
45
  if (!filter) {
46
46
  filesList.push(file)
@@ -62,7 +62,7 @@ export function getFiles(dirPath, filter = undefined, fsTmp = fs) {
62
62
  }
63
63
 
64
64
  export function getDirectories(dirPath, fsTmp = fs) {
65
- if (directoryExists(dirPath, fsTmp)) {
65
+ if (directoryExists({ dirPath, fs: fsTmp })) {
66
66
  return fsTmp
67
67
  .readdirSync(dirPath, { withFileTypes: true })
68
68
  .filter((dirent) => dirent.isDirectory())
@@ -73,7 +73,7 @@ export function getDirectories(dirPath, fsTmp = fs) {
73
73
  }
74
74
 
75
75
  export function deleteFile(filePath, fsTmp = fs) {
76
- if (!fileExists(filePath, fsTmp)) {
76
+ if (!fileExists({ filePath, fs: fsTmp })) {
77
77
  return false
78
78
  } else {
79
79
  return fsTmp.unlinkSync(filePath, { recursive: false, force: true })
@@ -117,19 +117,19 @@ export function saveFile(
117
117
  }
118
118
  }
119
119
 
120
- export function readFile(fileName, convert = true, fsTmp = fs) {
120
+ export function readFile(filePath, convert = true, fsTmp = fs) {
121
121
  try {
122
122
  let result = undefined
123
- if (fileExists(fileName, fsTmp)) {
124
- const data = fsTmp.readFileSync(fileName, {
123
+ if (fileExists({ filePath, fs: fsTmp })) {
124
+ const data = fsTmp.readFileSync(filePath, {
125
125
  encoding: 'utf8',
126
126
  flag: 'r',
127
127
  })
128
- if (convert && fileName.indexOf('.yaml') != -1) {
128
+ if (convert && filePath.indexOf('.yaml') != -1) {
129
129
  result = yaml.load(data)
130
- } else if (convert && fileName.indexOf('.json') != -1) {
130
+ } else if (convert && filePath.indexOf('.json') != -1) {
131
131
  result = JSON.parse(data)
132
- } else if (convert && fileName.indexOf('.xml') != -1) {
132
+ } else if (convert && filePath.indexOf('.xml') != -1) {
133
133
  // returns a promise
134
134
  result = convertXML(data)
135
135
  } else {
@@ -1,13 +1,9 @@
1
1
  import path from 'path'
2
- import { execSync } from 'node:child_process'
3
2
  import * as os from 'node:os'
4
- import { existsSync } from 'fs'
5
- import * as fileUtils from './fileUtils.js'
6
3
 
7
4
  const defaultDefinition = {
8
5
  git: {
9
6
  lastCommit: undefined,
10
- latestCommit: undefined,
11
7
  },
12
8
  local: {
13
9
  lastDate: undefined,
@@ -49,48 +45,90 @@ const status = {
49
45
  },
50
46
  }
51
47
 
52
- export function diff(
53
- dir,
54
- gitRef = 'HEAD',
55
- existsSyncStub = existsSync,
56
- execSyncStub = execSync,
57
- ) {
48
+ export function diff({ dir, gitRef = 'HEAD', existsSync, spawn }) {
58
49
  return new Promise((resolve, reject) => {
59
- if (!existsSyncStub(dir) || !existsSyncStub(path.join(dir, '.git'))) {
60
- reject(new Error(`The directory "${dir}" is not a git repository`))
61
- }
62
-
63
- let data = ''
64
50
  try {
65
- data = execSyncStub(
66
- `git diff --name-status --oneline --relative ${gitRef} -- *-party/*`,
67
- { cwd: dir, maxBuffer: 1024 * 1024 * 10 },
68
- ).toString()
51
+ if (!existsSync(dir)) {
52
+ throw new Error(`The directory "${dir}" does not exist`)
53
+ }
54
+ if (!existsSync(path.join(dir, '.git'))) {
55
+ throw new Error(
56
+ `The directory "${dir}" is not a git repository`,
57
+ )
58
+ }
59
+
60
+ const git = spawn('git', ['--version'])
61
+ git.on('error', (err) => {
62
+ throw new Error('Git is not installed on this machine')
63
+ })
64
+ git.on('close', (code) => {
65
+ if (code !== 0) {
66
+ reject(
67
+ new Error(
68
+ `git --version command failed with code ${code}`,
69
+ ),
70
+ )
71
+ }
72
+
73
+ const gitDiff = spawn(
74
+ 'git',
75
+ [
76
+ 'diff',
77
+ '--name-status',
78
+ '--oneline',
79
+ '--no-renames',
80
+ '--relative',
81
+ gitRef,
82
+ '--',
83
+ '*-party/*',
84
+ ],
85
+ { cwd: dir },
86
+ )
87
+ let data = ''
88
+ gitDiff.stdout.setEncoding('utf8')
89
+ gitDiff.stderr.on('data', (data) => {
90
+ if (data !== '')
91
+ reject(
92
+ new Error(
93
+ `git diff command failed with error: ${data}`,
94
+ ),
95
+ )
96
+ })
97
+ gitDiff.stdout.on('data', (chunk) => {
98
+ data += chunk
99
+ })
100
+ gitDiff.stdout.on('close', (code) => {
101
+ if (code !== 0 && code !== false) {
102
+ reject(
103
+ new Error(
104
+ `git diff command failed with code ${code}`,
105
+ ),
106
+ )
107
+ }
108
+ const gitData = data.toString().split(os.EOL)
109
+ const files = gitData.reduce((acc, gitRow) => {
110
+ if (gitRow.lastIndexOf('\t') > 0) {
111
+ const file = gitRow.split('\t')
112
+ if (file.slice(-1)[0] !== '') {
113
+ const statusType = status[file[0]]
114
+ acc.push({
115
+ type:
116
+ statusType !== undefined
117
+ ? statusType.type
118
+ : 'A',
119
+ path: file.slice(-1)[0],
120
+ action: statusType.action,
121
+ })
122
+ }
123
+ }
124
+ return acc
125
+ }, [])
126
+ resolve(files)
127
+ })
128
+ })
69
129
  } catch (error) {
70
130
  reject(error)
71
131
  }
72
-
73
- const gitData = data.toString().split(os.EOL)
74
- const files = gitData.reduce((acc, gitRow) => {
75
- if (gitRow.indexOf('\t') > 0) {
76
- const file = gitRow.split('\t')
77
- if (file.slice(-1) !== '') {
78
- const statusType =
79
- status[
80
- file[0] === file.slice(-1)
81
- ? 'A'
82
- : Array.from(file[0])[0]
83
- ]
84
- acc.push({
85
- type: statusType.type,
86
- path: file.slice(-1)[0],
87
- action: statusType.action,
88
- })
89
- }
90
- }
91
- return acc
92
- }, [])
93
- resolve(files)
94
132
  })
95
133
  }
96
134
 
@@ -110,39 +148,41 @@ export function log(dir, gitRef, execSyncStub = execSync) {
110
148
  }
111
149
  }
112
150
 
113
- export function lastCommit(
151
+ export function lastCommit({
114
152
  dir,
115
153
  fileName = 'index.yaml',
116
- existsSyncStub = existsSync,
117
- execSyncStub = execSync,
118
- fileUtilsStub = fileUtils,
119
- ) {
120
- try {
121
- const folder = path.resolve(dir, '.sfdx', 'sfparty')
122
- const filePath = path.resolve(folder, fileName)
123
- let lastCommit = undefined
154
+ existsSync,
155
+ execSync,
156
+ fileUtils,
157
+ }) {
158
+ return new Promise((resolve, reject) => {
159
+ try {
160
+ const folder = path.resolve(dir, '.sfdx', 'sfparty')
161
+ const filePath = path.resolve(folder, fileName)
162
+ let lastCommit = undefined
124
163
 
125
- fileUtilsStub.createDirectory(folder)
126
- if (existsSyncStub(filePath)) {
127
- const data = fileUtilsStub.readFile(filePath)
128
- if (data.git.lastCommit !== undefined) {
129
- lastCommit = data.git.lastCommit
164
+ fileUtils.createDirectory(folder)
165
+ if (existsSync(filePath)) {
166
+ const data = fileUtils.readFile(filePath)
167
+ if (data.git.lastCommit !== undefined) {
168
+ lastCommit = data.git.lastCommit
169
+ }
130
170
  }
171
+ const latestCommit = execSync(`git log --format=format:%H -1`, {
172
+ cwd: dir,
173
+ encoding: 'utf-8',
174
+ })
175
+ resolve({
176
+ lastCommit: lastCommit,
177
+ latestCommit: latestCommit,
178
+ })
179
+ } catch (error) {
180
+ reject(error)
131
181
  }
132
- const latestCommit = execSyncStub(`git log --format=format:%H -1`, {
133
- cwd: dir,
134
- encoding: 'utf-8',
135
- })
136
- return {
137
- lastCommit: lastCommit,
138
- latestCommit: latestCommit,
139
- }
140
- } catch (error) {
141
- throw new Error(error)
142
- }
182
+ })
143
183
  }
144
184
 
145
- export function updateLastCommit(dir, latest, fileUtilsStub = fileUtils) {
185
+ export function updateLastCommit({ dir, latest, fileUtils, fs }) {
146
186
  if (typeof latest !== 'string' && typeof latest !== 'undefined')
147
187
  throw new Error(
148
188
  `updateLastCommit received a ${typeof latest} instead of string`,
@@ -151,8 +191,8 @@ export function updateLastCommit(dir, latest, fileUtilsStub = fileUtils) {
151
191
  const folder = path.join(dir, '.sfdx', 'sfparty')
152
192
  const fileName = path.join(folder, 'index.yaml')
153
193
  let data = undefined
154
- if (fileUtilsStub.fileExists(fileName)) {
155
- data = fileUtilsStub.readFile(fileName)
194
+ if (fileUtils.fileExists({ filePath: fileName, fs })) {
195
+ data = fileUtils.readFile(fileName)
156
196
  }
157
197
 
158
198
  if (data === undefined) {
@@ -160,6 +200,6 @@ export function updateLastCommit(dir, latest, fileUtilsStub = fileUtils) {
160
200
  }
161
201
 
162
202
  data.git.lastCommit = latest
163
- fileUtilsStub.saveFile(data, fileName)
203
+ fileUtils.saveFile(data, fileName)
164
204
  }
165
205
  }
@@ -1,4 +1,5 @@
1
1
  import path from 'path'
2
+ import fs from 'fs'
2
3
  import * as packageDefinition from '../meta/Package.js'
3
4
 
4
5
  export class Package {
@@ -15,7 +16,10 @@ export class Package {
15
16
  throw new Error('Package not initialized')
16
17
 
17
18
  let fileName = path.resolve(that.xmlPath)
18
- if (fileUtils.fileExists(fileName) && global.git.append) {
19
+ if (
20
+ fileUtils.fileExists({ filePath: fileName, fs }) &&
21
+ global.git.append
22
+ ) {
19
23
  let data = fileUtils.readFile(fileName)
20
24
  data.then((json) => {
21
25
  try {