Skip to content

Commit ca7e642

Browse files
authored
Merge pull request #2559 from miragejs/restore-usingProxy
Restore usingProxy config
2 parents dc38525 + ffe05a7 commit ca7e642

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
const fs = require('fs');
3+
4+
function usingProxy() {
5+
const usingProxyArg = !!process.argv.filter(function (arg) {
6+
return (
7+
arg.indexOf('--proxy') === 0 ||
8+
arg.indexOf('-pr') === 0 ||
9+
arg.indexOf('-pxy') === 0
10+
);
11+
}).length;
12+
13+
let hasGeneratedProxies = false;
14+
const proxiesDir = `${process.env.PWD}/server/proxies`;
15+
try {
16+
fs.lstatSync(proxiesDir);
17+
hasGeneratedProxies = true;
18+
} catch (e) {
19+
// ignore
20+
}
21+
22+
return usingProxyArg || hasGeneratedProxies;
23+
}
24+
25+
module.exports = function (environment, appConfig) {
26+
appConfig['ember-cli-mirage'] = appConfig['ember-cli-mirage'] || {};
27+
appConfig['ember-cli-mirage'].usingProxy = usingProxy();
28+
appConfig['ember-cli-mirage'].useDefaultPassthroughs = true;
29+
30+
return {};
31+
};

0 commit comments

Comments
 (0)