|
| 1 | +/* eslint max-nested-callbacks: ["error", 5] */ |
1 | 2 | /* eslint-env mocha */
|
2 | 3 | 'use strict'
|
3 | 4 |
|
4 |
| -const fs = require('fs') |
5 |
| -const path = require('path') |
| 5 | +const os = require('os') |
6 | 6 | const expect = require('chai').expect
|
| 7 | +const repoVersion = require('ipfs-repo').repoVersion |
7 | 8 | const pkgversion = require('../../package.json').version
|
8 | 9 | const runOnAndOff = require('../utils/on-and-off')
|
9 | 10 |
|
10 |
| -function getRepoVersion (repoPath) { |
11 |
| - const versionPath = path.join(repoPath, 'version') |
12 |
| - return String(fs.readFileSync(versionPath)) |
13 |
| -} |
14 |
| - |
15 | 11 | describe('version', () => runOnAndOff((thing) => {
|
16 | 12 | let ipfs
|
17 |
| - let repoVersion |
18 | 13 |
|
19 | 14 | before(() => {
|
20 | 15 | ipfs = thing.ipfs
|
21 |
| - repoVersion = getRepoVersion(ipfs.repoPath) |
22 | 16 | })
|
23 | 17 |
|
24 |
| - it('get the version', () => { |
25 |
| - return ipfs('version').then((out) => { |
| 18 | + it('get the version', () => |
| 19 | + ipfs('version').then(out => |
26 | 20 | expect(out).to.eql(
|
27 | 21 | `js-ipfs version: ${pkgversion}\n`
|
28 | 22 | )
|
29 |
| - }) |
30 |
| - }) |
| 23 | + ) |
| 24 | + ) |
31 | 25 |
|
32 |
| - it('handles --number', () => { |
33 |
| - return ipfs('version --number').then(out => |
| 26 | + it('handles --number', () => |
| 27 | + ipfs('version --number').then(out => |
34 | 28 | expect(out).to.eql(`${pkgversion}\n`)
|
35 | 29 | )
|
36 |
| - }) |
| 30 | + ) |
37 | 31 |
|
38 |
| - it('handles --commit', () => { |
39 |
| - return ipfs('version --commit').then(out => |
| 32 | + it('handles --commit', () => |
| 33 | + ipfs('version --commit').then(out => |
40 | 34 | expect(out).to.eql(`js-ipfs version: ${pkgversion}-\n`)
|
41 | 35 | )
|
42 |
| - }) |
| 36 | + ) |
43 | 37 |
|
44 |
| - it('handles --all', () => { |
45 |
| - return ipfs('version --all').then(out => |
46 |
| - expect(out).to.include( |
47 |
| - `js-ipfs version: ${pkgversion}- |
48 |
| -Repo version: ${repoVersion} |
49 |
| -` |
50 |
| - ) |
| 38 | + describe('handles --all', function () { |
| 39 | + it('prints js-ipfs version', () => |
| 40 | + ipfs('version --all').then(out => { |
| 41 | + expect(out).to.include(`js-ipfs version: ${pkgversion}`) |
| 42 | + }) |
| 43 | + ) |
| 44 | + |
| 45 | + it('prints repo version', () => |
| 46 | + ipfs('version --all').then(out => { |
| 47 | + expect(out).to.include(`Repo version: ${repoVersion}`) |
| 48 | + }) |
| 49 | + ) |
| 50 | + |
| 51 | + it('prints arch/platform', () => |
| 52 | + ipfs('version --all').then(out => { |
| 53 | + expect(out).to.include(`System version: ${os.arch()}/${os.platform()}`) |
| 54 | + }) |
| 55 | + ) |
| 56 | + |
| 57 | + it('prints Node.js version', () => |
| 58 | + ipfs('version --all').then(out => { |
| 59 | + expect(out).to.include(`Node.js version: ${process.version}`) |
| 60 | + }) |
51 | 61 | )
|
52 | 62 | })
|
53 | 63 |
|
54 |
| - it('handles --repo', () => { |
55 |
| - return ipfs('version --repo').then(out => { |
| 64 | + it('handles --repo', () => |
| 65 | + ipfs('version --repo').then(out => |
56 | 66 | expect(out).to.eql(`${repoVersion}\n`)
|
57 |
| - }) |
58 |
| - }) |
| 67 | + ) |
| 68 | + ) |
59 | 69 | }))
|
0 commit comments