mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-03 04:26:39 +00:00
Fix Windows path issues
This commit is contained in:
parent
c48c77dbeb
commit
092a246b3d
@ -1,3 +1,4 @@
|
|||||||
|
os = require('os')
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
path = require('path')
|
path = require('path')
|
||||||
sinon = require('sinon')
|
sinon = require('sinon')
|
||||||
@ -46,7 +47,11 @@ describe 'Plugin:', ->
|
|||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@getNpmPathsStub = sinon.stub(plugin, 'getNpmPaths')
|
@getNpmPathsStub = sinon.stub(plugin, 'getNpmPaths')
|
||||||
@getNpmPathsStub.returns([ '/usr/lib/node_modules' ])
|
|
||||||
|
if os.platform() is 'win32'
|
||||||
|
@getNpmPathsStub.returns([ 'C:\\node_modules' ])
|
||||||
|
else
|
||||||
|
@getNpmPathsStub.returns([ '/usr/lib/node_modules' ])
|
||||||
|
|
||||||
@globSyncStub = sinon.stub(glob, 'sync')
|
@globSyncStub = sinon.stub(glob, 'sync')
|
||||||
@globSyncStub.returns [
|
@globSyncStub.returns [
|
||||||
@ -72,9 +77,14 @@ describe 'Plugin:', ->
|
|||||||
expect(fsPlus.isAbsolute(pluginPath)).to.be.true
|
expect(fsPlus.isAbsolute(pluginPath)).to.be.true
|
||||||
|
|
||||||
it 'should return the appropriate paths', ->
|
it 'should return the appropriate paths', ->
|
||||||
expect(@plugins[0]).to.equal('/usr/lib/node_modules/one')
|
if os.platform() is 'win32'
|
||||||
expect(@plugins[1]).to.equal('/usr/lib/node_modules/two')
|
expect(@plugins[0]).to.equal('C:\\node_modules\\one')
|
||||||
expect(@plugins[2]).to.equal('/usr/lib/node_modules/three')
|
expect(@plugins[1]).to.equal('C:\\node_modules\\two')
|
||||||
|
expect(@plugins[2]).to.equal('C:\\node_modules\\three')
|
||||||
|
else
|
||||||
|
expect(@plugins[0]).to.equal('/usr/lib/node_modules/one')
|
||||||
|
expect(@plugins[1]).to.equal('/usr/lib/node_modules/two')
|
||||||
|
expect(@plugins[2]).to.equal('/usr/lib/node_modules/three')
|
||||||
|
|
||||||
describe '#getNpmPaths()', ->
|
describe '#getNpmPaths()', ->
|
||||||
|
|
||||||
@ -104,9 +114,11 @@ describe 'Plugin:', ->
|
|||||||
mockFs.restore()
|
mockFs.restore()
|
||||||
|
|
||||||
it 'should throw an error', ->
|
it 'should throw an error', ->
|
||||||
|
pluginPath = path.join('/', 'hello', 'world')
|
||||||
|
pluginPathPackageJSON = path.join(pluginPath, 'package.json')
|
||||||
expect ->
|
expect ->
|
||||||
plugin.getPluginMeta('/hello/world')
|
plugin.getPluginMeta(pluginPath)
|
||||||
.to.throw('Invalid package.json: /hello/world/package.json')
|
.to.throw("Invalid package.json: #{pluginPathPackageJSON}")
|
||||||
|
|
||||||
describe 'given a plugin that exists', ->
|
describe 'given a plugin that exists', ->
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user