|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -const should = require('chai').should(); // eslint-disable-line |
| 3 | +const should = require('chai').should(); |
4 | 4 | const fs = require('hexo-fs');
|
5 | 5 | const pathFn = require('path');
|
6 | 6 |
|
7 |
| -describe('Find package', function() { |
| 7 | +describe('Find package', () => { |
8 | 8 | const findPkg = require('../../lib/find_pkg');
|
9 | 9 | const baseDir = pathFn.join(__dirname, 'find_pkg_test');
|
10 | 10 |
|
11 |
| - after(function() { |
12 |
| - return fs.rmdir(baseDir); |
13 |
| - }); |
| 11 | + after(() => fs.rmdir(baseDir)); |
14 | 12 |
|
15 |
| - it('not found', function() { |
16 |
| - return findPkg(baseDir, {}).then(function(path) { |
17 |
| - should.not.exist(path); |
18 |
| - }); |
19 |
| - }); |
| 13 | + it('not found', () => findPkg(baseDir, {}).then(path => { |
| 14 | + should.not.exist(path); |
| 15 | + })); |
20 | 16 |
|
21 |
| - it('found', function() { |
| 17 | + it('found', () => { |
22 | 18 | const pkgPath = pathFn.join(baseDir, 'package.json');
|
23 | 19 |
|
24 |
| - return fs.writeFile(pkgPath, '{"hexo": {}}').then(function() { |
25 |
| - return findPkg(baseDir, {}); |
26 |
| - }).then(function(path) { |
| 20 | + return fs.writeFile(pkgPath, '{"hexo": {}}').then(() => findPkg(baseDir, {})).then(path => { |
27 | 21 | path.should.eql(baseDir);
|
28 | 22 | return fs.unlink(pkgPath);
|
29 | 23 | });
|
30 | 24 | });
|
31 | 25 |
|
32 |
| - it('found in parent directory', function() { |
| 26 | + it('found in parent directory', () => { |
33 | 27 | const pkgPath = pathFn.join(baseDir, '../package.json');
|
34 | 28 |
|
35 |
| - return fs.writeFile(pkgPath, '{"hexo": {}}').then(function() { |
36 |
| - return findPkg(baseDir, {}); |
37 |
| - }).then(function(path) { |
| 29 | + return fs.writeFile(pkgPath, '{"hexo": {}}').then(() => findPkg(baseDir, {})).then(path => { |
38 | 30 | path.should.eql(pathFn.dirname(pkgPath));
|
39 | 31 | return fs.unlink(pkgPath);
|
40 | 32 | });
|
41 | 33 | });
|
42 | 34 |
|
43 |
| - it('found but don\'t have hexo data', function() { |
| 35 | + it('found but don\'t have hexo data', () => { |
44 | 36 | const pkgPath = pathFn.join(baseDir, 'package.json');
|
45 | 37 |
|
46 |
| - return fs.writeFile(pkgPath, '{"name": "hexo"}').then(function() { |
47 |
| - return findPkg(baseDir, {}); |
48 |
| - }).then(function(path) { |
| 38 | + return fs.writeFile(pkgPath, '{"name": "hexo"}').then(() => findPkg(baseDir, {})).then(path => { |
49 | 39 | should.not.exist(path);
|
50 | 40 | return fs.unlink(pkgPath);
|
51 | 41 | });
|
52 | 42 | });
|
53 | 43 |
|
54 |
| - it('relative cwd', function() { |
| 44 | + it('relative cwd', () => { |
55 | 45 | const pkgPath = pathFn.join(baseDir, 'test', 'package.json');
|
56 | 46 |
|
57 |
| - return fs.writeFile(pkgPath, '{"hexo": {}}').then(function() { |
58 |
| - return findPkg(baseDir, {cwd: 'test'}); |
59 |
| - }).then(function(path) { |
| 47 | + return fs.writeFile(pkgPath, '{"hexo": {}}').then(() => findPkg(baseDir, {cwd: 'test'})).then(path => { |
60 | 48 | path.should.eql(pathFn.dirname(pkgPath));
|
61 | 49 | return fs.unlink(pkgPath);
|
62 | 50 | });
|
63 | 51 | });
|
64 | 52 |
|
65 |
| - it('specify cwd but don\'t have hexo data', function() { |
66 |
| - return findPkg(baseDir, {cwd: 'test'}).then(function(path) { |
67 |
| - should.not.exist(path); |
68 |
| - }); |
69 |
| - }); |
| 53 | + it('specify cwd but don\'t have hexo data', () => findPkg(baseDir, {cwd: 'test'}).then(path => { |
| 54 | + should.not.exist(path); |
| 55 | + })); |
70 | 56 |
|
71 |
| - it('absolute cwd', function() { |
| 57 | + it('absolute cwd', () => { |
72 | 58 | const pkgPath = pathFn.join(baseDir, 'test', 'package.json');
|
73 | 59 | const cwd = pathFn.dirname(pkgPath);
|
74 | 60 |
|
75 |
| - return fs.writeFile(pkgPath, '{"hexo": {}}').then(function() { |
76 |
| - return findPkg(baseDir, {cwd: cwd}); |
77 |
| - }).then(function(path) { |
| 61 | + return fs.writeFile(pkgPath, '{"hexo": {}}').then(() => findPkg(baseDir, {cwd})).then(path => { |
78 | 62 | path.should.eql(cwd);
|
79 | 63 | return fs.unlink(pkgPath);
|
80 | 64 | });
|
|
0 commit comments