dotenv-diff 2.1.5 → 2.1.6

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.
@@ -37,14 +37,34 @@ export async function run(program) {
37
37
  if (opts.envFlag && opts.exampleFlag) {
38
38
  const envExists = fs.existsSync(opts.envFlag);
39
39
  const exExists = fs.existsSync(opts.exampleFlag);
40
+ // Handle missing files with prompting (unless in CI mode)
40
41
  if (!envExists || !exExists) {
41
- if (!envExists) {
42
- console.error(chalk.red(`❌ Error: --env file not found: ${path.basename(opts.envFlag)}`));
42
+ // Check if we should prompt for file creation
43
+ if (!opts.isCiMode) {
44
+ const res = await ensureFilesOrPrompt({
45
+ cwd: opts.cwd,
46
+ primaryEnv: opts.envFlag,
47
+ primaryExample: opts.exampleFlag,
48
+ alreadyWarnedMissingEnv: false,
49
+ isYesMode: opts.isYesMode,
50
+ isCiMode: opts.isCiMode,
51
+ });
52
+ if (res.shouldExit) {
53
+ if (opts.json)
54
+ console.log(JSON.stringify([], null, 2));
55
+ process.exit(res.exitCode);
56
+ }
43
57
  }
44
- if (!exExists) {
45
- console.error(chalk.red(`❌ Error: --example file not found: ${path.basename(opts.exampleFlag)}`));
58
+ else {
59
+ // In CI mode, we just show errors and exit
60
+ if (!envExists) {
61
+ console.error(chalk.red(`❌ Error: --env file not found: ${path.basename(opts.envFlag)}`));
62
+ }
63
+ if (!exExists) {
64
+ console.error(chalk.red(`❌ Error: --example file not found: ${path.basename(opts.exampleFlag)}`));
65
+ }
66
+ process.exit(1);
46
67
  }
47
- process.exit(1);
48
68
  }
49
69
  const report = [];
50
70
  const { exitWithError } = await compareMany([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotenv-diff",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "type": "module",
5
5
  "description": "Find differences between .env and .env.example / .env.* files. And optionally scan your codebase to find environment variables in use.",
6
6
  "bin": {