Skip to content

Commit

Permalink
fix(@angular/cli): convert before option in .npmrc to Date
Browse files Browse the repository at this point in the history
Previously, the `before` option in the npmrc was not converted properly to a date.

See: https://docs.npmjs.com/cli/v8/using-npm/config#before

Closes #24685

(cherry picked from commit 545c180)
  • Loading branch information
alan-agius4 authored and dgp1130 committed Feb 10, 2023
1 parent 384ad29 commit df07ab1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/angular/cli/src/utilities/package-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ function normalizeOptions(
} catch {}
}
break;
case 'before':
options['before'] =
typeof substitutedValue === 'string' ? new Date(substitutedValue) : substitutedValue;
break;
default:
options[key] = substitutedValue;
break;
Expand Down
8 changes: 8 additions & 0 deletions tests/legacy-cli/e2e/tests/commands/add/npm-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { writeFile } from '../../../utils/fs';
import { ng } from '../../../utils/process';

export default async function () {
// Works with before option
await writeFile('.npmrc', `before=${new Date().toISOString()}`);
await ng('add', '@angular/pwa', '--skip-confirmation');
}

0 comments on commit df07ab1

Please sign in to comment.