-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c48373
commit a0adc82
Showing
11 changed files
with
836 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ sudo: false | |
language: node_js | ||
node_js: | ||
- 4 | ||
- 5 | ||
- 6 | ||
- stable | ||
|
||
# Make sure we have new NPM. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict' | ||
|
||
// Start a disposable node, and get access to the api | ||
// print the node id, and kill the temporary daemon | ||
|
||
// IPFS_PATH will point to /tmp/ipfs_***** and will be | ||
// cleaned up when the process exits. | ||
|
||
const ipfsd = require('ipfsd-ctl') | ||
|
||
ipfsd.disposableApi((err, ipfs) => { | ||
if (err) throw err | ||
ipfs.id((err, id) => { | ||
if (err) throw err | ||
console.log(id) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
'use strict' | ||
|
||
const run = require('subcomandante') | ||
const once = require('once') | ||
|
||
function exec (cmd, args, opts, handlers) { | ||
opts = opts || {} | ||
let err = '' | ||
let result = '' | ||
let callback | ||
|
||
// Handy method if we just want the result and err returned in a callback | ||
if (typeof handlers === 'function') { | ||
callback = once(handlers) | ||
handlers = { | ||
error: callback, | ||
data (data) { | ||
result += data | ||
}, | ||
done () { | ||
if (err) { | ||
return callback(new Error(err)) | ||
} | ||
callback(null, result.trim()) | ||
} | ||
} | ||
} | ||
|
||
// The listeners that will actually be set on the process | ||
const listeners = { | ||
data: handlers.data, | ||
error (data) { | ||
err += data | ||
}, | ||
done: once((code) => { | ||
if (typeof code === 'number' && code !== 0) { | ||
return handlers.error( | ||
new Error(`non-zero exit code ${code}\n | ||
while running: ${cmd} ${args.join(' ')}\n\n | ||
${err}`) | ||
) | ||
} | ||
if (handlers.done) { | ||
handlers.done() | ||
} | ||
}) | ||
} | ||
|
||
const command = run(cmd, args, opts) | ||
|
||
if (listeners.data) { | ||
command.stdout.on('data', listeners.data) | ||
} | ||
|
||
command.stderr.on('data', listeners.error) | ||
|
||
// If command fails to execute return directly to the handler | ||
command.on('error', handlers.error) | ||
|
||
command.on('close', listeners.done) | ||
command.on('exit', listeners.done) | ||
|
||
return command | ||
} | ||
|
||
module.exports = exec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.