UNPKG

2.43 kBJavaScriptView Raw
1/*───────────────────────────────────────────────────────────────────────────*\
2 │ Copyright (C) 2014 eBay Software Foundation │
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 \*───────────────────────────────────────────────────────────────────────────*/
16'use strict';
17
18var path = require('path');
19var thing = require('core-util-is');
20
21
22exports.env = {
23 development: /^dev/i,
24 test : /^test/i,
25 staging : /^stag/i,
26 production : /^prod/i
27};
28
29
30exports.isAbsolute = function absPath(file) {
31 if (thing.isString(file)) {
32 return path.resolve(file) === file;
33 }
34 return false;
35};
36
37
38exports.merge = function marge(src, dest) {
39 // NOTE: Do not merge arrays.
40 if (thing.isObject(src) && !thing.isArray(src) && !thing.isNullOrUndefined(dest)) {
41
42 Object.getOwnPropertyNames(src).forEach(function(prop) {
43 var descriptor;
44 descriptor = Object.getOwnPropertyDescriptor(src, prop);
45 descriptor.value = marge(descriptor.value, dest[prop]);
46 Object.defineProperty(dest, prop, descriptor);
47 });
48
49 return dest;
50
51 }
52
53 return src;
54};