Skip to content

Commit d5966f6

Browse files
committed
Breaking: Drop node <0.10 support, switch to mocha + expect for testing
1 parent 18f583c commit d5966f6

File tree

6 files changed

+56
-40
lines changed

6 files changed

+56
-40
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "gulp"
3+
}

.jscsrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"preset": "gulp"
3+
}

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
sudo: false
12
language: node_js
23
node_js:
3-
- "0.7"
4-
- "0.8"
5-
- "0.9"
6-
- "0.10"
4+
- '6'
5+
- '5'
6+
- '4'
7+
- '0.12'
8+
- '0.10'
79
after_script:
8-
- npm run coveralls
10+
- npm run coveralls

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
var path = require('path');
22

33
module.exports = function(npath, ext) {
4-
if (typeof npath !== 'string') return npath;
5-
if (npath.length === 0) return npath;
4+
if (typeof npath !== 'string') {
5+
return npath;
6+
}
67

7-
var nFileName = path.basename(npath, path.extname(npath))+ext;
8+
if (npath.length === 0) {
9+
return npath;
10+
}
11+
12+
var nFileName = path.basename(npath, path.extname(npath)) + ext;
813
return path.join(path.dirname(npath), nFileName);
9-
};
14+
};

package.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@
88
"main": "./index.js",
99
"dependencies": {},
1010
"devDependencies": {
11-
"mocha": "~1.17.0",
12-
"should": "~3.1.0",
13-
"mocha-lcov-reporter": "~0.0.1",
14-
"coveralls": "~2.6.1",
15-
"istanbul": "~0.2.3",
16-
"rimraf": "~2.2.5",
17-
"jshint": "~2.4.1"
11+
"eslint": "^1.10.3",
12+
"eslint-config-gulp": "^2.0.0",
13+
"expect": "^1.16.0",
14+
"istanbul": "^0.4.3",
15+
"istanbul-coveralls": "^1.0.3",
16+
"jscs": "^2.3.5",
17+
"jscs-preset-gulp": "^1.0.0",
18+
"mocha": "^2.4.5"
1819
},
1920
"scripts": {
20-
"test": "mocha --reporter spec && jshint",
21-
"coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"
21+
"lint": "eslint . && jscs index.js test/",
22+
"pretest": "npm run lint",
23+
"test": "mocha --async-only",
24+
"cover": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly",
25+
"coveralls": "npm run cover && istanbul-coveralls"
2226
},
2327
"engines": {
2428
"node": ">= 0.4"

test/main.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,50 @@
1-
var replaceExt = require('../');
1+
'use strict';
2+
23
var path = require('path');
3-
var should = require('should');
4-
require('mocha');
4+
5+
var expect = require('expect');
6+
7+
var replaceExt = require('../');
58

69
describe('replace-ext', function() {
7-
it('should return a valid replaced extension on nested', function(done) {
10+
11+
it('returns a valid replaced extension on long path', function(done) {
812
var fname = path.join(__dirname, './fixtures/test.coffee');
913
var expected = path.join(__dirname, './fixtures/test.js');
10-
var nu = replaceExt(fname, '.js');
11-
should.exist(nu);
12-
nu.should.equal(expected);
14+
var result = replaceExt(fname, '.js');
15+
expect(result).toEqual(expected);
1316
done();
1417
});
1518

16-
it('should return a valid replaced extension on flat', function(done) {
19+
it('returns a valid replaced extension on basename', function(done) {
1720
var fname = 'test.coffee';
1821
var expected = 'test.js';
19-
var nu = replaceExt(fname, '.js');
20-
should.exist(nu);
21-
nu.should.equal(expected);
22+
var result = replaceExt(fname, '.js');
23+
expect(result).toEqual(expected);
2224
done();
2325
});
2426

2527
it('should not return a valid replaced extension on empty string', function(done) {
2628
var fname = '';
2729
var expected = '';
28-
var nu = replaceExt(fname, '.js');
29-
should.exist(nu);
30-
nu.should.equal(expected);
30+
var result = replaceExt(fname, '.js');
31+
expect(result).toEqual(expected);
3132
done();
3233
});
3334

34-
it('should return a valid removed extension on nested', function(done) {
35+
it('returns a valid removed extension on long path', function(done) {
3536
var fname = path.join(__dirname, './fixtures/test.coffee');
3637
var expected = path.join(__dirname, './fixtures/test');
37-
var nu = replaceExt(fname, '');
38-
should.exist(nu);
39-
nu.should.equal(expected);
38+
var result = replaceExt(fname, '');
39+
expect(result).toEqual(expected);
4040
done();
4141
});
4242

43-
it('should return a valid added extension on nested', function(done) {
43+
it('returns a valid added extension on long path', function(done) {
4444
var fname = path.join(__dirname, './fixtures/test');
4545
var expected = path.join(__dirname, './fixtures/test.js');
46-
var nu = replaceExt(fname, '.js');
47-
should.exist(nu);
48-
nu.should.equal(expected);
46+
var result = replaceExt(fname, '.js');
47+
expect(result).toEqual(expected);
4948
done();
5049
});
5150
});

0 commit comments

Comments
 (0)