/
defaults.js
67 lines (62 loc) · 1.6 KB
/
defaults.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const Glob = require('glob')
const childProcess = require('node:child_process')
const Fs = require('node:fs')
const util = require('node:util')
const execFileAsync = util.promisify(childProcess.execFile)
/**
* Default path to workspace root
*/
const DEFAULT_ROOT = process.cwd()
exports.DEFAULT_ROOT = DEFAULT_ROOT
/**
* Default options provided to a {@link SpawnFn}
*/
const DEFAULT_SPAWN_OPTS = Object.freeze(
/** @type {import('node:child_process').SpawnOptions} */ ({
cwd: DEFAULT_ROOT,
stdio: 'inherit',
shell: true,
})
)
exports.DEFAULT_SPAWN_OPTS = DEFAULT_SPAWN_OPTS
/**
* Default options provided to a {@link GlobFn}
*/
const DEFAULT_GLOB_OPTS = Object.freeze(
/** @type {import('glob').GlobOptionsWithFileTypesTrue} */ ({
cwd: DEFAULT_ROOT,
withFileTypes: true,
ignore: {
ignored: /** @param {import('./types').GlobDirent} p */ (p) =>
!p.parent || !p.isDirectory(),
},
})
)
exports.DEFAULT_GLOB_OPTS = DEFAULT_GLOB_OPTS
/**
* Default capabilities for Laverna
*/
const DEFAULT_CAPS = Object.freeze(
/** @type {import('./types').AllLavernaCapabilities} */ ({
fs: Fs,
glob: Glob.glob,
execFile: execFileAsync,
spawn: childProcess.spawn,
// eslint-disable-next-line no-restricted-properties
parseJson: JSON.parse,
console: globalThis.console,
})
)
exports.DEFAULT_CAPS = DEFAULT_CAPS
/**
* Default options for Laverna
*/
const DEFAULT_OPTS = Object.freeze(
/** @type {import('./types').AllLavernaOptions} */ ({
dryRun: false,
yes: false,
root: DEFAULT_ROOT,
newPkg: [],
})
)
exports.DEFAULT_OPTS = DEFAULT_OPTS