Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaces path to .asar.unpacked if cmd includes .asar/node_modules #155

Merged
merged 18 commits into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"

# cache:
# - node_modules

platform:
- x64

install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm install

test_script:
- node --version
- npm --version
- npm test

build: off

version: "{build}"
10 changes: 9 additions & 1 deletion src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ const GRACE_PERIOD = 7500 // amount of ms to wait before sigkill
function findIpfsExecutable () {
const rootPath = process.env.testpath ? process.env.testpath : __dirname

const appRoot = path.join(rootPath, '..')
let appRoot = path.join(rootPath, '..')
// If inside <appname>.asar try to load from .asar.unpacked
// this only works if asar was built with
// asar --unpack-dir=node_modules/go-ipfs-dep/* (not tested)
// or
// electron-packager ./ --asar.unpackDir=node_modules/go-ipfs-dep
if (appRoot.includes(`.asar${path.sep}`)) {
appRoot = appRoot.replace(`.asar${path.sep}`, `.asar.unpacked${path.sep}`)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add this to the README too? It is fine to leave it here, but I want to make sure it this note is searchable and linkable to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

const depPath = path.join('go-ipfs-dep', 'go-ipfs', 'ipfs')
const npm3Path = path.join(appRoot, '../', depPath)
const npm2Path = path.join(appRoot, 'node_modules', depPath)
Expand Down
11 changes: 9 additions & 2 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('ipfs executable path', () => {
Node = require('../src/node.js')
var node = new Node()
expect(node.exec)
.to.eql('/tmp/ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs/ipfs')
.to.eql(path.normalize('/tmp/ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs/ipfs'))
rimraf('/tmp/ipfsd-ctl-test', done)
})
})
Expand All @@ -58,7 +58,7 @@ describe('ipfs executable path', () => {
expect(
node.exec
).to.be.eql(
'/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs/ipfs'
path.normalize('/tmp/ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs/ipfs')
)
rimraf('/tmp/ipfsd-ctl-test', done)
})
Expand Down Expand Up @@ -390,10 +390,17 @@ describe('daemons', () => {
if (err) throw err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is a temporary skip, is it ok if I just os.platform() === 'win32' ?

https://nodejs.org/api/os.html#os_os_platform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


const added = res[res.length - 1]
expect(res.length).to.equal(2)
expect(added).to.have.property('path', 'fixtures')
expect(added).to.have.property(
'hash',
'QmXkiTdnfRJjiQREtF5dWf2X4V9awNHQSn9YGofwVY4qUU'
)
expect(res[0]).to.have.property('path', 'fixtures/test.txt')
expect(res[0]).to.have.property(
'hash',
'Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD'
)
done()
})
})
Expand Down