-
Notifications
You must be signed in to change notification settings - Fork 62
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
Changes from all commits
e9ac8b0
c641866
03ea8d5
60fa938
a6b1347
9f53ce8
1b9dcf8
279f58f
3fc9347
135dca4
46c422e
92841df
5190a48
32e8200
f3e49d5
0510863
d74578b
d1a7bdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint no-console: 0 */ | ||
'use strict' | ||
|
||
// Start a disposable node, and get access to the api | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
test-ipfs-app* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint no-console: 0 */ | ||
'use strict' | ||
|
||
const { app, ipcMain, BrowserWindow } = require('electron') | ||
const ipfsd = require('ipfsd-ctl') | ||
|
||
app.on('ready', () => { | ||
const win = new BrowserWindow({ | ||
title: 'loading' | ||
}) | ||
win.loadURL(`file://${app.getAppPath()}/public/index.html`) | ||
}) | ||
|
||
ipcMain.on('start', ({ sender }) => { | ||
console.log('starting disposable IPFS') | ||
sender.send('message', 'starting disposable IPFS') | ||
|
||
ipfsd.disposableApi((err, ipfs) => { | ||
if (err) { | ||
sender.send('error', err) | ||
throw err | ||
} | ||
console.log('get id') | ||
sender.send('message', 'get id') | ||
ipfs.id(function (err, id) { | ||
if (err) { | ||
sender.send('error', err) | ||
throw err | ||
} | ||
console.log('got id', id) | ||
sender.send('id', JSON.stringify(id)) | ||
}) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "test-ipfs-app", | ||
"private": true, | ||
"main": "./app.js", | ||
"dependencies": { | ||
"ipfsd-ctl": "*" | ||
}, | ||
"devDependencies": { | ||
"electron": "^1.7.6", | ||
"electron-packager": "^9.0.0" | ||
}, | ||
"scripts": { | ||
"start": "electron .", | ||
"package": "electron-packager ./ --overwrite --asar.unpackDir=node_modules/go-ipfs-dep" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!doctype html> | ||
<title>loading</title> | ||
<button>test ipfs app</button> | ||
<script> | ||
const { ipcRenderer } = require('electron') | ||
|
||
ipcRenderer.on('message', (event, msg) => appendPre(msg)) | ||
ipcRenderer.on('error', (event, err) => appendPre(err)) | ||
|
||
document.querySelector('button') | ||
.addEventListener('click', () => { | ||
ipcRenderer.once('id', (event, id) => appendPre(id)) | ||
ipcRenderer.send('start') | ||
}) | ||
|
||
function appendPre(data) { | ||
const pre = document.createElement('pre') | ||
pre.textContent = data | ||
document.body.appendChild(pre) | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Packaging | ||
|
||
```bash | ||
npm install | ||
npm run package | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint no-console: 0 */ | ||
'use strict' | ||
|
||
var ipfsd = require('../') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint no-console: 0 */ | ||
'use strict' | ||
|
||
var ipfsd = require('../') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ const os = require('os') | |
const exec = require('../src/exec') | ||
const ipfsd = require('../src') | ||
|
||
const isWindows = os.platform() === 'win32' | ||
|
||
describe('ipfs executable path', () => { | ||
let Node | ||
|
||
|
@@ -37,7 +39,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) | ||
}) | ||
}) | ||
|
@@ -58,7 +60,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) | ||
}) | ||
|
@@ -384,16 +386,46 @@ describe('daemons', () => { | |
}) | ||
}) | ||
|
||
// skip on windows for now | ||
// https://github.com/ipfs/js-ipfsd-ctl/pull/155#issuecomment-326970190 | ||
// fails on windows see https://github.com/ipfs/js-ipfs-api/issues/408 | ||
if (isWindows) { | ||
it.skip('uses the correct ipfs-api') | ||
return // does not continue this test on win | ||
} | ||
|
||
// NOTE: if you change ./fixtures, the hash will need to be changed | ||
it('uses the correct ipfs-api', (done) => { | ||
ipfs.util.addFromFs(path.join(__dirname, 'fixtures/'), { recursive: true }, (err, res) => { | ||
if (err) throw err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see: #155 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it is a temporary skip, is it ok if I just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get https://github.com/ipfs/npm-go-ipfs-dep/blob/master/src/index.js#L47-L60 sorry!! :( it also depends on another module (go-platform) and file https://github.com/ipfs/npm-go-ipfs-dep/blob/master/src/check-support.js |
||
|
||
const added = res[res.length - 1] | ||
|
||
// Temporary: Need to see what is going on on windows | ||
expect(res).to.deep.equal([ | ||
{ | ||
path: 'fixtures/test.txt', | ||
hash: 'Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD', | ||
size: 19 | ||
}, | ||
{ | ||
path: 'fixtures', | ||
hash: 'QmXkiTdnfRJjiQREtF5dWf2X4V9awNHQSn9YGofwVY4qUU', | ||
size: 73 | ||
} | ||
]) | ||
|
||
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() | ||
}) | ||
}) | ||
|
@@ -404,11 +436,15 @@ describe('daemons', () => { | |
const dir = `${os.tmpdir()}/tmp-${Date.now() + '-' + Math.random().toString(36)}` | ||
|
||
const check = (cb) => { | ||
if (fs.existsSync(path.join(dir, 'repo.lock'))) { | ||
cb(new Error('repo.lock not removed')) | ||
} | ||
if (fs.existsSync(path.join(dir, 'api'))) { | ||
cb(new Error('api file not removed')) | ||
// skip on windows | ||
// https://github.com/ipfs/js-ipfsd-ctl/pull/155#issuecomment-326983530 | ||
if (!isWindows) { | ||
if (fs.existsSync(path.join(dir, 'repo.lock'))) { | ||
cb(new Error('repo.lock not removed')) | ||
} | ||
if (fs.existsSync(path.join(dir, 'api'))) { | ||
cb(new Error('api file not removed')) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
} | ||
cb() | ||
} | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure