1 | ;
|
2 | // Copyright 2018 Google LLC
|
3 | //
|
4 | // Licensed under the Apache License, Version 2.0 (the "License");
|
5 | // you may not use this file except in compliance with the License.
|
6 | // You may obtain a copy of the License at
|
7 | //
|
8 | // http://www.apache.org/licenses/LICENSE-2.0
|
9 | //
|
10 | // Unless required by applicable law or agreed to in writing, software
|
11 | // distributed under the License is distributed on an "AS IS" BASIS,
|
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | // See the License for the specific language governing permissions and
|
14 | // limitations under the License.
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | exports.warn = exports.WarningTypes = void 0;
|
17 | var WarningTypes;
|
18 | (function (WarningTypes) {
|
19 | WarningTypes["WARNING"] = "Warning";
|
20 | WarningTypes["DEPRECATION"] = "DeprecationWarning";
|
21 | })(WarningTypes || (exports.WarningTypes = WarningTypes = {}));
|
22 | function warn(warning) {
|
23 | // Only show a given warning once
|
24 | if (warning.warned) {
|
25 | return;
|
26 | }
|
27 | warning.warned = true;
|
28 | if (typeof process !== 'undefined' && process.emitWarning) {
|
29 | // @types/node doesn't recognize the emitWarning syntax which
|
30 | // accepts a config object, so `as any` it is
|
31 | // https://nodejs.org/docs/latest-v8.x/api/process.html#process_process_emitwarning_warning_options
|
32 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
33 | process.emitWarning(warning.message, warning);
|
34 | }
|
35 | else {
|
36 | console.warn(warning.message);
|
37 | }
|
38 | }
|
39 | exports.warn = warn;
|