@netlify/config 18.2.4 → 18.2.5

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.
Files changed (56) hide show
  1. package/bin.js +5 -0
  2. package/lib/api/build_settings.js +20 -33
  3. package/lib/api/client.js +10 -13
  4. package/lib/api/site_info.js +48 -56
  5. package/lib/base.js +10 -18
  6. package/lib/bin/flags.js +134 -142
  7. package/lib/bin/main.js +49 -63
  8. package/lib/build_dir.js +11 -15
  9. package/lib/cached_config.js +14 -17
  10. package/lib/case.js +16 -35
  11. package/lib/context.js +62 -84
  12. package/lib/default.js +18 -22
  13. package/lib/env/envelope.js +23 -23
  14. package/lib/env/git.js +18 -18
  15. package/lib/env/main.js +127 -179
  16. package/lib/error.js +19 -27
  17. package/lib/events.js +18 -19
  18. package/lib/files.js +63 -87
  19. package/lib/functions_config.js +36 -52
  20. package/lib/headers.js +17 -27
  21. package/lib/inline_config.js +6 -7
  22. package/lib/log/cleanup.js +54 -82
  23. package/lib/log/logger.js +25 -36
  24. package/lib/log/main.js +31 -40
  25. package/lib/log/messages.js +56 -95
  26. package/lib/log/options.js +24 -38
  27. package/lib/log/serialize.js +3 -4
  28. package/lib/log/theme.js +10 -11
  29. package/lib/main.js +188 -263
  30. package/lib/merge.js +25 -35
  31. package/lib/merge_normalize.js +17 -24
  32. package/lib/mutations/apply.js +53 -65
  33. package/lib/mutations/config_prop_name.js +6 -8
  34. package/lib/mutations/update.js +79 -98
  35. package/lib/normalize.js +24 -28
  36. package/lib/options/base.js +39 -51
  37. package/lib/options/branch.js +23 -26
  38. package/lib/options/feature_flags.js +7 -10
  39. package/lib/options/main.js +76 -96
  40. package/lib/options/repository_root.js +11 -16
  41. package/lib/origin.js +22 -29
  42. package/lib/parse.js +42 -55
  43. package/lib/path.js +29 -40
  44. package/lib/redirects.js +16 -26
  45. package/lib/simplify.js +66 -92
  46. package/lib/utils/group.js +5 -6
  47. package/lib/utils/remove_falsy.js +9 -13
  48. package/lib/utils/set.js +19 -25
  49. package/lib/utils/toml.js +13 -16
  50. package/lib/validate/context.js +24 -43
  51. package/lib/validate/example.js +20 -27
  52. package/lib/validate/helpers.js +17 -23
  53. package/lib/validate/identical.js +8 -12
  54. package/lib/validate/main.js +83 -127
  55. package/lib/validate/validations.js +243 -257
  56. package/package.json +13 -8
package/lib/bin/main.js CHANGED
@@ -1,73 +1,59 @@
1
1
  #!/usr/bin/env node
2
-
3
- import { promises as fs } from 'fs'
4
- import { dirname } from 'path'
5
- import process from 'process'
6
-
7
- import fastSafeStringify from 'fast-safe-stringify'
8
- import omit from 'omit.js'
9
-
10
- import { isUserError } from '../error.js'
11
- import { resolveConfig } from '../main.js'
12
-
13
- import { parseFlags } from './flags.js'
14
-
2
+ import { promises as fs } from 'fs';
3
+ import { dirname } from 'path';
4
+ import process from 'process';
5
+ import fastSafeStringify from 'fast-safe-stringify';
6
+ import omit from 'omit.js';
7
+ import { isUserError } from '../error.js';
8
+ import { resolveConfig } from '../main.js';
9
+ import { parseFlags } from './flags.js';
15
10
  // CLI entry point
16
11
  const runCli = async function () {
17
- try {
18
- const { stable, output = DEFAULT_OUTPUT, ...flags } = parseFlags()
19
- const result = await resolveConfig(flags)
20
- await handleCliSuccess(result, stable, output)
21
- } catch (error) {
22
- handleCliError(error)
23
- }
24
- }
25
-
26
- const DEFAULT_OUTPUT = '-'
27
-
12
+ try {
13
+ const { stable, output = DEFAULT_OUTPUT, ...flags } = parseFlags();
14
+ const result = await resolveConfig(flags);
15
+ await handleCliSuccess(result, stable, output);
16
+ }
17
+ catch (error) {
18
+ handleCliError(error);
19
+ }
20
+ };
21
+ const DEFAULT_OUTPUT = '-';
28
22
  // The result is output as JSON on success (exit code 0)
29
23
  const handleCliSuccess = async function (result, stable, output) {
30
- const resultA = serializeApi(result)
31
- const resultB = omit.default(resultA, SECRET_PROPERTIES)
32
- const stringifyFunc = stable ? fastSafeStringify.stableStringify : JSON.stringify
33
- const resultJson = stringifyFunc(resultB, null, 2)
34
- await outputResult(resultJson, output)
35
- process.exitCode = 0
36
- }
37
-
24
+ const resultA = serializeApi(result);
25
+ const resultB = omit.default(resultA, SECRET_PROPERTIES);
26
+ const stringifyFunc = stable ? fastSafeStringify.stableStringify : JSON.stringify;
27
+ const resultJson = stringifyFunc(resultB, null, 2);
28
+ await outputResult(resultJson, output);
29
+ process.exitCode = 0;
30
+ };
38
31
  const outputResult = async function (resultJson, output) {
39
- if (output === '-') {
40
- console.log(resultJson)
41
- return
42
- }
43
-
44
- await fs.mkdir(dirname(output), { recursive: true })
45
- await fs.writeFile(output, resultJson)
46
- }
47
-
32
+ if (output === '-') {
33
+ console.log(resultJson);
34
+ return;
35
+ }
36
+ await fs.mkdir(dirname(output), { recursive: true });
37
+ await fs.writeFile(output, resultJson);
38
+ };
48
39
  // `api` is not JSON-serializable, so we remove it
49
40
  // We still indicate it as a boolean
50
41
  const serializeApi = function ({ api, ...result }) {
51
- if (api === undefined) {
52
- return result
53
- }
54
-
55
- return { ...result, hasApi: true }
56
- }
57
-
58
- const SECRET_PROPERTIES = ['token']
59
-
42
+ if (api === undefined) {
43
+ return result;
44
+ }
45
+ return { ...result, hasApi: true };
46
+ };
47
+ const SECRET_PROPERTIES = ['token'];
60
48
  const handleCliError = function (error) {
61
- // Errors caused by users do not show stack traces and have exit code 1
62
- if (isUserError(error)) {
63
- console.error(error.message)
64
- process.exitCode = 1
65
- return
66
- }
67
-
68
- // Internal errors / bugs have exit code 2
69
- console.error(error.stack)
70
- process.exitCode = 2
71
- }
72
-
73
- runCli()
49
+ // Errors caused by users do not show stack traces and have exit code 1
50
+ if (isUserError(error)) {
51
+ console.error(error.message);
52
+ process.exitCode = 1;
53
+ return;
54
+ }
55
+ // Internal errors / bugs have exit code 2
56
+ console.error(error.stack);
57
+ process.exitCode = 2;
58
+ };
59
+ runCli();
package/lib/build_dir.js CHANGED
@@ -1,26 +1,22 @@
1
- import { isDirectory } from 'path-type'
2
-
3
- import { throwUserError } from './error.js'
4
-
1
+ import { isDirectory } from 'path-type';
2
+ import { throwUserError } from './error.js';
5
3
  // Retrieve the build directory used to resolve most paths.
6
4
  // This is (in priority order):
7
5
  // - `build.base`
8
6
  // - `--repositoryRoot`
9
7
  // - the current directory (default value of `--repositoryRoot`)
10
8
  export const getBuildDir = async function (repositoryRoot, base) {
11
- const buildDir = base === undefined ? repositoryRoot : base
12
- await checkBuildDir(buildDir, repositoryRoot)
13
- return buildDir
14
- }
15
-
9
+ const buildDir = base === undefined ? repositoryRoot : base;
10
+ await checkBuildDir(buildDir, repositoryRoot);
11
+ return buildDir;
12
+ };
16
13
  // The build directory is used as the current directory of build commands and
17
14
  // build plugins. Therefore it must exist.
18
15
  // We already check `repositoryRoot` earlier in the code, so only need to check
19
16
  // `buildDir` when it is the base directory instead.
20
17
  const checkBuildDir = async function (buildDir, repositoryRoot) {
21
- if (buildDir === repositoryRoot || (await isDirectory(buildDir))) {
22
- return
23
- }
24
-
25
- throwUserError(`Base directory does not exist: ${buildDir}`)
26
- }
18
+ if (buildDir === repositoryRoot || (await isDirectory(buildDir))) {
19
+ return;
20
+ }
21
+ throwUserError(`Base directory does not exist: ${buildDir}`);
22
+ };
@@ -1,5 +1,4 @@
1
- import { promises as fs } from 'fs'
2
-
1
+ import { promises as fs } from 'fs';
3
2
  // Performance optimization when @netlify/config caller has already previously
4
3
  // called it and cached the result.
5
4
  // This is used by the buildbot which:
@@ -7,23 +6,21 @@ import { promises as fs } from 'fs'
7
6
  // - later calls @netlify/build, which runs @netlify/config under the hood
8
7
  // This is also used by Netlify CLI.
9
8
  export const getCachedConfig = async function ({ cachedConfig, cachedConfigPath, token, api }) {
10
- const parsedCachedConfig = await parseCachedConfig(cachedConfig, cachedConfigPath)
11
- // The CLI does not print some properties when they are not serializable or
12
- // are confidential. Those will be missing from `cachedConfig`. The caller
13
- // must supply them again when using `cachedConfig`.
14
- return parsedCachedConfig === undefined ? undefined : { token, ...parsedCachedConfig, api }
15
- }
16
-
9
+ const parsedCachedConfig = await parseCachedConfig(cachedConfig, cachedConfigPath);
10
+ // The CLI does not print some properties when they are not serializable or
11
+ // are confidential. Those will be missing from `cachedConfig`. The caller
12
+ // must supply them again when using `cachedConfig`.
13
+ return parsedCachedConfig === undefined ? undefined : { token, ...parsedCachedConfig, api };
14
+ };
17
15
  // `cachedConfig` is a plain object while `cachedConfigPath` is a file path to
18
16
  // a JSON file. The former is useful in programmatic usage while the second one
19
17
  // is useful in CLI usage, to avoid hitting the OS limits if the configuration
20
18
  // file is too big.
21
19
  const parseCachedConfig = async function (cachedConfig, cachedConfigPath) {
22
- if (cachedConfig !== undefined) {
23
- return cachedConfig
24
- }
25
-
26
- if (cachedConfigPath !== undefined) {
27
- return JSON.parse(await fs.readFile(cachedConfigPath))
28
- }
29
- }
20
+ if (cachedConfig !== undefined) {
21
+ return cachedConfig;
22
+ }
23
+ if (cachedConfigPath !== undefined) {
24
+ return JSON.parse(await fs.readFile(cachedConfigPath));
25
+ }
26
+ };
package/lib/case.js CHANGED
@@ -1,37 +1,18 @@
1
1
  // Some properties can be optionally capitalized. We normalize them to lowercase
2
2
  export const normalizeConfigCase = function ({ Build, build = Build, ...config }) {
3
- const buildA = normalizeBuildCase(build)
4
- return { ...config, build: buildA }
5
- }
6
-
7
- const normalizeBuildCase = function ({
8
- Base,
9
- base = Base,
10
- Command,
11
- command = Command,
12
- Edge_functions: EdgeFunctions,
13
- edge_functions: edgeFunctions = EdgeFunctions,
14
- Environment,
15
- environment = Environment,
16
- Functions,
17
- functions = Functions,
18
- Ignore,
19
- ignore = Ignore,
20
- Processing,
21
- processing = Processing,
22
- Publish,
23
- publish = Publish,
24
- ...build
25
- } = {}) {
26
- return {
27
- ...build,
28
- base,
29
- command,
30
- edge_functions: edgeFunctions,
31
- environment,
32
- functions,
33
- ignore,
34
- processing,
35
- publish,
36
- }
37
- }
3
+ const buildA = normalizeBuildCase(build);
4
+ return { ...config, build: buildA };
5
+ };
6
+ const normalizeBuildCase = function ({ Base, base = Base, Command, command = Command, Edge_functions: EdgeFunctions, edge_functions: edgeFunctions = EdgeFunctions, Environment, environment = Environment, Functions, functions = Functions, Ignore, ignore = Ignore, Processing, processing = Processing, Publish, publish = Publish, ...build } = {}) {
7
+ return {
8
+ ...build,
9
+ base,
10
+ command,
11
+ edge_functions: edgeFunctions,
12
+ environment,
13
+ functions,
14
+ ignore,
15
+ processing,
16
+ publish,
17
+ };
18
+ };
package/lib/context.js CHANGED
@@ -1,108 +1,86 @@
1
- import isPlainObj from 'is-plain-obj'
2
- import mapObj from 'map-obj'
3
-
4
- import { mergeConfigs } from './merge.js'
5
- import { normalizeBeforeConfigMerge } from './merge_normalize.js'
6
- import { validateContextsPluginsConfig } from './validate/context.js'
7
- import { validatePreContextConfig } from './validate/main.js'
8
-
1
+ import isPlainObj from 'is-plain-obj';
2
+ import mapObj from 'map-obj';
3
+ import { mergeConfigs } from './merge.js';
4
+ import { normalizeBeforeConfigMerge } from './merge_normalize.js';
5
+ import { validateContextsPluginsConfig } from './validate/context.js';
6
+ import { validatePreContextConfig } from './validate/main.js';
9
7
  // Validate and normalize `config.context.*`
10
8
  export const normalizeContextProps = function ({ config, config: { context: contextProps }, origin }) {
11
- if (contextProps === undefined) {
12
- return config
13
- }
14
-
15
- validatePreContextConfig(config)
16
-
17
- const allContextProps = mapObj(contextProps, (key, contextConfig) => [key, addNamespace(contextConfig)])
18
- const normalizedContextProps = mapObj(allContextProps, (key, contextConfig) => [
19
- key,
20
- normalizeBeforeConfigMerge(contextConfig, origin),
21
- ])
22
- return { ...config, context: normalizedContextProps }
23
- }
24
-
9
+ if (contextProps === undefined) {
10
+ return config;
11
+ }
12
+ validatePreContextConfig(config);
13
+ const allContextProps = mapObj(contextProps, (key, contextConfig) => [key, addNamespace(contextConfig)]);
14
+ const normalizedContextProps = mapObj(allContextProps, (key, contextConfig) => [
15
+ key,
16
+ normalizeBeforeConfigMerge(contextConfig, origin),
17
+ ]);
18
+ return { ...config, context: normalizedContextProps };
19
+ };
25
20
  // Merge `config.context.{CONTEXT|BRANCH}.*` to `config.build.*` or `config.*`
26
21
  // CONTEXT is the `--context` CLI flag.
27
22
  // BRANCH is the `--branch` CLI flag.
28
- export const mergeContext = function ({
29
- config: { context: contextProps, ...config },
30
- config: { plugins },
31
- context,
32
- branch,
33
- logs,
34
- }) {
35
- if (contextProps === undefined) {
36
- return config
37
- }
38
-
39
- const contexts = [context, branch]
40
- validateContextsPluginsConfig({ contextProps, plugins, contexts, logs })
41
- const filteredContextProps = contexts.map((key) => contextProps[key]).filter(Boolean)
42
- return mergeConfigs([config, ...filteredContextProps])
43
- }
44
-
23
+ export const mergeContext = function ({ config: { context: contextProps, ...config }, config: { plugins }, context, branch, logs, }) {
24
+ if (contextProps === undefined) {
25
+ return config;
26
+ }
27
+ const contexts = [context, branch];
28
+ validateContextsPluginsConfig({ contextProps, plugins, contexts, logs });
29
+ const filteredContextProps = contexts.map((key) => contextProps[key]).filter(Boolean);
30
+ return mergeConfigs([config, ...filteredContextProps]);
31
+ };
45
32
  // `config.context.{context}.*` properties are merged either to `config.*` or
46
33
  // to `config.build.*`. We distinguish between both by checking the property
47
34
  // name.
48
- const addNamespace = (contextConfig) => Object.entries(contextConfig).reduce(addNamespacedProperty, {})
49
-
35
+ const addNamespace = (contextConfig) => Object.entries(contextConfig).reduce(addNamespacedProperty, {});
50
36
  const addNamespacedProperty = function (contextConfig, [key, value]) {
51
- return isBuildProperty(key, value)
52
- ? { ...contextConfig, build: { ...contextConfig.build, [key]: value } }
53
- : { ...contextConfig, [key]: value }
54
- }
55
-
37
+ return isBuildProperty(key, value)
38
+ ? { ...contextConfig, build: { ...contextConfig.build, [key]: value } }
39
+ : { ...contextConfig, [key]: value };
40
+ };
56
41
  const isBuildProperty = function (key, value) {
57
- return BUILD_PROPERTIES.has(key) && !isFunctionsConfig(key, value) && !isEdgeFunctionsConfig(key, value)
58
- }
59
-
42
+ return BUILD_PROPERTIES.has(key) && !isFunctionsConfig(key, value) && !isEdgeFunctionsConfig(key, value);
43
+ };
60
44
  // All properties in `config.build.*`
61
45
  const BUILD_PROPERTIES = new Set([
62
- 'base',
63
- 'command',
64
- 'edge_functions',
65
- 'environment',
66
- 'functions',
67
- 'ignore',
68
- 'processing',
69
- 'publish',
70
- ])
71
-
46
+ 'base',
47
+ 'command',
48
+ 'edge_functions',
49
+ 'environment',
50
+ 'functions',
51
+ 'ignore',
52
+ 'processing',
53
+ 'publish',
54
+ ]);
72
55
  // `config.functions` is a plain object while `config.build.functions` is a
73
56
  // string.
74
57
  const isFunctionsConfig = function (key, value) {
75
- return key === 'functions' && isPlainObj(value)
76
- }
77
-
58
+ return key === 'functions' && isPlainObj(value);
59
+ };
78
60
  // `config.edge_functions` is an array of objects while
79
61
  // `config.build.edge_functions` is a string.
80
62
  const isEdgeFunctionsConfig = function (key, value) {
81
- return key === 'edge_functions' && Array.isArray(value)
82
- }
83
-
63
+ return key === 'edge_functions' && Array.isArray(value);
64
+ };
84
65
  // Ensure that `inlineConfig` has higher priority than context properties by
85
66
  // assigining it to `context.*`. Still keep it at the top-level as well since
86
67
  // some properties are not handled context-sensitively by the API.
87
68
  // Takes into account that `context.{context}.build.*` is the same as
88
69
  // `context.{context}.*`
89
70
  export const ensureConfigPriority = function ({ build = {}, ...config }, context, branch) {
90
- const base = {
91
- ...config,
92
- build,
93
- }
94
-
95
- // remove the redirects to not have context specific redirects.
96
- // The redirects should be only on the root level.
97
- // eslint-disable-next-line fp/no-delete, no-param-reassign
98
- delete config.redirects
99
-
100
- return {
101
- ...base,
102
- context: {
103
- ...config.context,
104
- [context]: { ...config, ...build, build },
105
- [branch]: { ...config, ...build, build },
106
- },
107
- }
108
- }
71
+ const base = {
72
+ ...config,
73
+ build,
74
+ };
75
+ // remove the redirects to not have context specific redirects.
76
+ // The redirects should be only on the root level.
77
+ delete config.redirects;
78
+ return {
79
+ ...base,
80
+ context: {
81
+ ...config.context,
82
+ [context]: { ...config, ...build, build },
83
+ [branch]: { ...config, ...build, build },
84
+ },
85
+ };
86
+ };
package/lib/default.js CHANGED
@@ -1,31 +1,27 @@
1
- import { addBuildSettings } from './api/build_settings.js'
2
- import { logDefaultConfig } from './log/main.js'
3
-
1
+ import { addBuildSettings } from './api/build_settings.js';
2
+ import { logDefaultConfig } from './log/main.js';
4
3
  // Retrieve default configuration file. It has less priority and it also does
5
4
  // not get normalized, merged with contexts, etc.
6
5
  export const parseDefaultConfig = function ({ defaultConfig, base, baseRelDir, siteInfo, logs, debug }) {
7
- const defaultConfigB = addDefaultConfigBase(defaultConfig, base)
8
- const { defaultConfig: defaultConfigC, baseRelDir: baseRelDirA = DEFAULT_BASE_REL_DIR } = addBuildSettings({
9
- defaultConfig: defaultConfigB,
10
- baseRelDir,
11
- siteInfo,
12
- })
13
- logDefaultConfig(defaultConfigC, { logs, debug, baseRelDir: baseRelDirA })
14
- return { defaultConfig: defaultConfigC, baseRelDir: baseRelDirA }
15
- }
16
-
6
+ const defaultConfigB = addDefaultConfigBase(defaultConfig, base);
7
+ const { defaultConfig: defaultConfigC, baseRelDir: baseRelDirA = DEFAULT_BASE_REL_DIR } = addBuildSettings({
8
+ defaultConfig: defaultConfigB,
9
+ baseRelDir,
10
+ siteInfo,
11
+ });
12
+ logDefaultConfig(defaultConfigC, { logs, debug, baseRelDir: baseRelDirA });
13
+ return { defaultConfig: defaultConfigC, baseRelDir: baseRelDirA };
14
+ };
17
15
  // When the `base` was overridden, add it to `defaultConfig` so it behaves
18
16
  // as if it had been specified in the UI settings
19
17
  const addDefaultConfigBase = function (defaultConfig, base) {
20
- if (base === undefined) {
21
- return defaultConfig
22
- }
23
-
24
- const { build = {} } = defaultConfig
25
- return { ...defaultConfig, build: { ...build, base } }
26
- }
27
-
18
+ if (base === undefined) {
19
+ return defaultConfig;
20
+ }
21
+ const { build = {} } = defaultConfig;
22
+ return { ...defaultConfig, build: { ...build, base } };
23
+ };
28
24
  // `baseRelDir` should default to `true` only if the option was not passed and
29
25
  // it could be retrieved from the `siteInfo`, which is why the default value
30
26
  // is assigned later than other properties.
31
- const DEFAULT_BASE_REL_DIR = true
27
+ const DEFAULT_BASE_REL_DIR = true;
@@ -1,24 +1,24 @@
1
1
  export const getEnvelope = async function ({ api, accountId, siteId }) {
2
- if (accountId === undefined) {
3
- return {}
4
- }
5
- try {
6
- const environmentVariables = await api.getEnvVars({ accountId, siteId })
7
- // eslint-disable-next-line fp/no-mutating-methods
8
- const sortedEnvVarsFromDevContext = environmentVariables
9
- .sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1))
10
- .reduce((acc, cur) => {
11
- const envVar = cur.values.find((val) => ['dev', 'all'].includes(val.context))
12
- if (envVar && envVar.value) {
13
- return {
14
- ...acc,
15
- [cur.key]: envVar.value,
16
- }
17
- }
18
- return acc
19
- }, {})
20
- return sortedEnvVarsFromDevContext
21
- } catch {
22
- return {}
23
- }
24
- }
2
+ if (accountId === undefined) {
3
+ return {};
4
+ }
5
+ try {
6
+ const environmentVariables = await api.getEnvVars({ accountId, siteId });
7
+ const sortedEnvVarsFromDevContext = environmentVariables
8
+ .sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1))
9
+ .reduce((acc, cur) => {
10
+ const envVar = cur.values.find((val) => ['dev', 'all'].includes(val.context));
11
+ if (envVar && envVar.value) {
12
+ return {
13
+ ...acc,
14
+ [cur.key]: envVar.value,
15
+ };
16
+ }
17
+ return acc;
18
+ }, {});
19
+ return sortedEnvVarsFromDevContext;
20
+ }
21
+ catch {
22
+ return {};
23
+ }
24
+ };
package/lib/env/git.js CHANGED
@@ -1,23 +1,23 @@
1
- import { execa } from 'execa'
2
-
3
- import { removeFalsy } from '../utils/remove_falsy.js'
4
-
1
+ import { execa } from 'execa';
2
+ import { removeFalsy } from '../utils/remove_falsy.js';
5
3
  // Retrieve git-related information for use in environment variables.
6
4
  // git is optional and there might be not git repository.
7
5
  // We purposely keep this decoupled from the git utility.
8
6
  export const getGitEnv = async function (buildDir, branch) {
9
- const [COMMIT_REF, CACHED_COMMIT_REF] = await Promise.all([
10
- git(['rev-parse', 'HEAD'], buildDir),
11
- git(['rev-parse', 'HEAD^'], buildDir),
12
- ])
13
- const gitEnv = { BRANCH: branch, HEAD: branch, COMMIT_REF, CACHED_COMMIT_REF, PULL_REQUEST: 'false' }
14
- const gitEnvA = removeFalsy(gitEnv)
15
- return gitEnvA
16
- }
17
-
7
+ const [COMMIT_REF, CACHED_COMMIT_REF] = await Promise.all([
8
+ git(['rev-parse', 'HEAD'], buildDir),
9
+ git(['rev-parse', 'HEAD^'], buildDir),
10
+ ]);
11
+ const gitEnv = { BRANCH: branch, HEAD: branch, COMMIT_REF, CACHED_COMMIT_REF, PULL_REQUEST: 'false' };
12
+ const gitEnvA = removeFalsy(gitEnv);
13
+ return gitEnvA;
14
+ };
18
15
  const git = async function (args, cwd) {
19
- try {
20
- const { stdout } = await execa('git', args, { cwd })
21
- return stdout
22
- } catch {}
23
- }
16
+ try {
17
+ const { stdout } = await execa('git', args, { cwd });
18
+ return stdout;
19
+ }
20
+ catch {
21
+ // continue regardless error
22
+ }
23
+ };