Skip to content

Commit 212b4f7

Browse files
author
zhaoxuxu
committed
feature: off specific path ans subpath
1 parent 096b052 commit 212b4f7

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gleam

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@badeggg/mock-api",
3-
"version": "0.10.0",
3+
"version": "0.11.0",
44
"description": "mock api",
55
"main": "./src/index.js",
66
"bin": {

src/fake-services/example/off

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Created by @zhaoxuxu at @2021-3-16
2+
# Last updated by @zhaoxuxu at @2021-3-16
3+
4+
When this file exists, the mocking on this path and all subpath
5+
are considered 404.
6+
7+
'OFF' or 'off' naming is fine. Other case combinations are
8+
file-system dependent.
9+

src/middlewares/mapToRes/cd.js

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ const _ = require('lodash');
99
* }
1010
*/
1111
function cdOne(folder, current) {
12+
const isOff = ( // turn off this fake service path
13+
fs.existsSync(pathUtil.resolve(current.path, 'off'))
14+
|| fs.existsSync(pathUtil.resolve(current.path, 'OFF'))
15+
);
16+
if (isOff) {
17+
return false;
18+
}
19+
1220
let testNext = pathUtil.resolve(current.path, folder);
1321
if (fs.existsSync(testNext) && fs.statSync(testNext).isDirectory()) {
1422
return _.merge({}, current, {

0 commit comments

Comments
 (0)