1 | path = require 'path'
|
2 |
|
3 | logger = require 'torch'
|
4 | should = require 'should'
|
5 |
|
6 | findProjectRoot = require '../lib/findProjectRoot'
|
7 |
|
8 | sampleProjDir = path.join __dirname, '../sample/project1'
|
9 |
|
10 | describe 'findProjectRoot', ->
|
11 | it 'should stop when it finds an package.json below another', (done) ->
|
12 | testDir = path.join(sampleProjDir, 'a1', 'a2')
|
13 |
|
14 | expected = path.join(sampleProjDir, 'a1')
|
15 | root = findProjectRoot(testDir)
|
16 | root.should.eql expected
|
17 | done()
|
18 |
|
19 | it 'should stop when it finds a package.json', (done) ->
|
20 | testDir = path.join(sampleProjDir, 'b1', 'b2', 'b3')
|
21 |
|
22 | root = findProjectRoot(testDir)
|
23 | root.should.eql sampleProjDir
|
24 | done()
|
25 |
|
26 | it 'should return undefined when it cannot find a package.json', (done) ->
|
27 | testDir = '/'
|
28 |
|
29 | root = findProjectRoot(testDir)
|
30 | should.not.exist root
|
31 | done()
|