UNPKG

2.5 kBJavaScriptView Raw
1/*───────────────────────────────────────────────────────────────────────────*\
2 │ Copyright (C) 2016 PayPal │
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 \*───────────────────────────────────────────────────────────────────────────*/
16import Path from 'path';
17import Thing from 'core-util-is';
18
19
20export default {
21
22 env: {
23 development: /^dev/i,
24 test : /^test/i,
25 staging : /^stag/i,
26 production : /^prod/i
27 },
28
29 isAbsolute(path) {
30 if (Thing.isString(path)) {
31 path = Path.normalize(path);
32 return path === Path.resolve(path);
33 }
34 return false;
35 },
36
37 merge(src, dest) {
38 // NOTE: Do not merge arrays and only merge objects into objects.
39 if (!Thing.isArray(src) && Thing.isObject(src) && Thing.isObject(dest)) {
40 for (let prop of Object.getOwnPropertyNames(src)) {
41 let descriptor = Object.getOwnPropertyDescriptor(src, prop);
42 descriptor.value = this.merge(descriptor.value, dest[prop]);
43 Object.defineProperty(dest, prop, descriptor);
44 }
45 return dest;
46 }
47
48 return src;
49 }
50
51}