Skip to content

Commit d579e42

Browse files
committed
Upgrade package.json and test cases
1 parent 36c747c commit d579e42

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"description": "Gulp plugin for fitlering files that differ from some base git branch",
55
"main": "index.js",
66
"scripts": {
7-
"test": "./node_modules/mocha/bin/mocha"
7+
"test": "npx mocha"
88
},
99
"author": {
10-
"name" : "Alexander Myshov",
11-
"url": "https://github.com/myshov"
10+
"name": "Alexander Myshov",
11+
"url": "https://github.com/myshov"
1212
},
1313
"repository": {
1414
"type": "git",
@@ -27,6 +27,8 @@
2727
"node": ">=0.12.0"
2828
},
2929
"keywords": [
30-
"gulpplugin", "git", "filtering"
30+
"gulpplugin",
31+
"git",
32+
"filtering"
3133
]
3234
}

test/isFileChanged.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,32 @@
11
var assert = require('assert');
22
var rewire = require('rewire');
3+
var path = require('path');
34

45
var gulpGitFlowDiff = rewire('../');
5-
gulpGitFlowDiff.__set__({
6-
process: {
7-
cwd: function() {
8-
return '/home/user/dev'
9-
}
10-
}
11-
});
126

137
describe('gulp-giflow-diff isFileChanged', function() {
14-
process.cwd = function() {
15-
return '/home/user/dev'
16-
};
17-
8+
const basePath = process.cwd();
189
it('should return true if there is file in list of changed files', function(done) {
1910
var fileMocked = {};
20-
fileMocked.path = 'https://github.com/home/user/dev/src/file33.js';
11+
fileMocked.path = path.join(basePath, 'src/file33.js');
2112
var filesChanged = [
2213
'src/file11.js',
2314
'src/file22.js',
2415
'src/file33.js'
25-
];
16+
].map(filePath => path.join(basePath, filePath));
2617
var result = gulpGitFlowDiff.isFileChanged(fileMocked, filesChanged);
2718
assert.equal(result, true);
2819
done();
2920
});
3021

3122
it('should return false if there is no file in list of changed files', function(done) {
3223
var fileMocked = {};
33-
fileMocked.path = 'https://github.com/usr/home/user/dev/src/file44.js';
24+
fileMocked.path = path.join(basePath, 'src/file44.js');
3425
var filesChanged = [
3526
'src/file11.js',
3627
'src/file22.js',
3728
'src/file33.js'
38-
];
29+
].map(filePath => path.join(basePath, filePath));
3930
var result = gulpGitFlowDiff.isFileChanged(fileMocked, filesChanged);
4031
assert.equal(result, false);
4132
done();

0 commit comments

Comments
 (0)