@programinglive/commiter 1.1.0 → 1.1.1

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,23 @@
1
+ const fs = require('fs');
2
+ const Module = require('module');
3
+
4
+ const targetPath = require.resolve('standard-version/lib/lifecycles/changelog');
5
+
6
+ if (!Module._commiterPatchedFsFok) {
7
+ const originalLoader = Module._extensions['.js'];
8
+
9
+ Module._extensions['.js'] = function patchedLoader(module, filename) {
10
+ if (filename === targetPath) {
11
+ let source = fs.readFileSync(filename, 'utf8');
12
+ if (source.includes('fs.F_OK')) {
13
+ source = source.replace(/fs\.F_OK/g, 'fs.constants.F_OK');
14
+ }
15
+ module._compile(source, filename);
16
+ return;
17
+ }
18
+
19
+ return originalLoader(module, filename);
20
+ };
21
+
22
+ Module._commiterPatchedFsFok = true;
23
+ }
@@ -4,6 +4,11 @@ const { spawnSync } = require('child_process');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
 
7
+ const fsFokPreloadPath = path.join(__dirname, 'preload', 'fs-f-ok.cjs');
8
+ const FS_FOK_PRELOAD_FLAG = buildPreloadFlag(fsFokPreloadPath);
9
+
10
+ require('./preload/fs-f-ok.cjs');
11
+
7
12
  const VALID_RELEASE_TYPES = new Set([
8
13
  'major',
9
14
  'minor',
@@ -141,8 +146,10 @@ function runRelease({ argv = process.argv, env = process.env, spawn = spawnSync
141
146
  }
142
147
 
143
148
  const standardVersionBin = require.resolve('standard-version/bin/cli.js');
149
+ const childEnv = appendPreloadToNodeOptions(env, FS_FOK_PRELOAD_FLAG);
144
150
  return spawn(process.execPath, [standardVersionBin, ...standardVersionArgs], {
145
- stdio: 'inherit'
151
+ stdio: 'inherit',
152
+ env: childEnv
146
153
  });
147
154
  }
148
155
 
@@ -169,3 +176,18 @@ module.exports = {
169
176
  runProjectTests,
170
177
  runRelease
171
178
  };
179
+
180
+ function buildPreloadFlag(filePath) {
181
+ const resolved = path.resolve(filePath);
182
+ const escaped = resolved.includes(' ')
183
+ ? `"${resolved.replace(/"/g, '\"')}"`
184
+ : resolved;
185
+ return `--require ${escaped}`;
186
+ }
187
+
188
+ function appendPreloadToNodeOptions(env, preloadFlag) {
189
+ const nextEnv = { ...env };
190
+ const existing = typeof nextEnv.NODE_OPTIONS === 'string' ? nextEnv.NODE_OPTIONS.trim() : '';
191
+ nextEnv.NODE_OPTIONS = existing ? `${existing} ${preloadFlag}` : preloadFlag;
192
+ return nextEnv;
193
+ }