UNPKG

1.46 kBJavaScriptView Raw
1'use strict';
2// This file is ES6 because it needs to be executed as is.
3
4// Check if the current directory contains '.angular-cli.json'. If it does, show a message to the user that they
5// should use the migration script.
6
7const fs = require('fs');
8const path = require('path');
9const os = require('os');
10
11
12let found = false;
13let current = path.dirname(path.dirname(__dirname));
14while (current !== path.dirname(current)) {
15 if (fs.existsSync(path.join(current, 'angular-cli.json'))
16 || fs.existsSync(path.join(current, '.angular-cli.json'))) {
17 found = os.homedir() !== current || fs.existsSync(path.join(current, 'package.json'));
18 break;
19 }
20 if (fs.existsSync(path.join(current, 'angular.json'))
21 || fs.existsSync(path.join(current, '.angular.json'))
22 || fs.existsSync(path.join(current, 'package.json'))) {
23 break;
24 }
25
26 current = path.dirname(current);
27}
28
29
30if (found) {
31 // ------------------------------------------------------------------------------------------
32 // If changing this message, please update the same message in
33 // `packages/@angular/cli/models/command-runner.ts`
34
35 // eslint-disable-next-line no-console
36 console.error(`\u001b[31m
37 ${'='.repeat(80)}
38 The Angular CLI configuration format has been changed, and your existing configuration can
39 be updated automatically by running the following command:
40
41 ng update @angular/cli
42 ${'='.repeat(80)}
43 \u001b[39m`.replace(/^ {4}/gm, ''));
44}