File tree Expand file tree Collapse file tree
packages/ember-cli-mirage/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ;
You can’t perform that action at this time.
0 commit comments