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

Added pause/resume, refactored code, improved command line interface (and more) #515

Closed
wants to merge 31 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
53d6335
got tests for pause/resume to pass
whitef0x0 Nov 27, 2015
cd1d84c
added nice cli for seed quitting interface
whitef0x0 Nov 27, 2015
61d1afb
added resume/pause support for audio/video streaming
whitef0x0 Nov 27, 2015
c68d39d
got gracefulExit to stop hanging
whitef0x0 Nov 27, 2015
67c9c47
added disableSeeding option for torrent
whitef0x0 Nov 27, 2015
01a685a
added getBySearch method
whitef0x0 Nov 27, 2015
b003801
added documentation for getBySearch
whitef0x0 Nov 27, 2015
9f4768f
fixed cli for search
whitef0x0 Nov 27, 2015
9ceac78
added tests for addBySearch()
whitef0x0 Nov 27, 2015
2415418
got all tests to pass but one
whitef0x0 Nov 30, 2015
be0b718
got download /path/to/file cmd.js test to pass
whitef0x0 Dec 1, 2015
b1430c8
updated browser code
whitef0x0 Dec 2, 2015
3db0dad
fixed cmd
whitef0x0 Dec 2, 2015
488bcc9
updated minified build
whitef0x0 Dec 2, 2015
10f9cc2
added unit tests for torrent.js
whitef0x0 Dec 3, 2015
53ea5f1
added tests for appendTo
whitef0x0 Dec 4, 2015
af023ce
added .npmignore
whitef0x0 Dec 4, 2015
74382ee
got zuul tests to run
whitef0x0 Dec 4, 2015
341ed30
removed extraneous user stories
whitef0x0 Dec 4, 2015
428a9ac
added documentation for new methods to the README
whitef0x0 Dec 4, 2015
8752393
added test cli interface
whitef0x0 Dec 5, 2015
2737d3f
updated travis-ci build
whitef0x0 Dec 5, 2015
9067381
started travis-ci
whitef0x0 Dec 5, 2015
254eae0
fixed package.json and travis.yml; got travis-ci to pass
whitef0x0 Dec 5, 2015
7f03f39
added main property to bower.json
whitef0x0 Dec 5, 2015
cb9849c
added ignore to bower.json
whitef0x0 Dec 5, 2015
d82559d
removed search functionality
whitef0x0 Dec 5, 2015
7610325
removed bower
whitef0x0 Dec 5, 2015
4d44ccd
Create description.md
whitef0x0 Dec 11, 2015
9f56b0c
Update test.js
whitef0x0 Dec 11, 2015
82fffad
Added description of changes
whitef0x0 Dec 11, 2015
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Update test.js

  • Loading branch information
whitef0x0 committed Dec 11, 2015
commit 9f56b0c664180ce718f7ad27501a0c8c80a1b7fa
@@ -1,107 +1,18 @@
#!/usr/bin/env node

var spawn = require('cross-spawn-async')
var minimist = require('minimist')
var fs = require('fs')
var path = require('path')
var clivas = require('clivas')

var argv = minimist(process.argv.slice(2), {
alias: {
l: 'local',
b: 'browser',
s: 'standard'
},
boolean: [ // options that are always boolean
'local',
'standard',
'browser',
'help'
]
})

var runBrowserTests = (!process.env.TRAVIS_PULL_REQUEST ||
process.env.TRAVIS_PULL_REQUEST === 'false') && argv.local

var command = argv._[0]
if (argv.help || command === 'help') {
runHelp()
} else if (command === 'coverage' || command === 'test') {
runTest(command)
} else {
clivas.line('webtorrent-test: \'' + command + '\' is not a webtorrent-test command. See \'webtorrent-test --help\'')
}
var runBrowserTests = !process.env.TRAVIS_PULL_REQUEST ||
process.env.TRAVIS_PULL_REQUEST === 'false'

function runHelp () {
fs.readFileSync(path.join(__dirname, 'ascii-logo.txt'), 'utf8')
.split('\n')
.forEach(function (line) {
clivas.line('{bold:' + line.substring(0, 20) + '}{red:' + line.substring(20) + '}')
})

console.log(function () {
/*
Usage:
webtorrent-test [command] <options>
Example:
webtorrent-test test --local --browser
Commands:
test Run the nodejs test suite
coverage Generate test coverage data (via istanbul)
Options:
-l, --local run test suite for local development
-b, --browser run browser test suite (along with existing test suite)
-b, --standard run js `standard` code linting tool before test suite
*/
}.toString().split(/\n/).slice(2, -2).join('\n'))
process.exit(0)
}

function runTest (testType) {
var testCommand = testType
var browserTestCommand = 'test'

if (argv.local) {
if (testType === 'coverage') {
testCommand += '-local'
} else {
testCommand += '-node'
}

if (argv.browser) {
browserTestCommand += '-browser-local'
}
} else {
browserTestCommand += '-browser'
testCommand += '-node'
}

if (argv.standard) {
var node = spawn('sh', ['-c', 'node_modules/.bin/standard'], { stdio: 'inherit' })
node.on('close', function (code) {
if (code === 0) {
executeTest(testCommand, browserTestCommand)
}
var node = spawn('npm', ['run', 'test-node'], { stdio: 'inherit' })
node.on('close', function (code) {
if (code === 0 && runBrowserTests) {
var browser = spawn('npm', ['run', 'test-browser'], { stdio: 'inherit' })
browser.on('close', function (code) {
process.exit(code)
})
} else {
executeTest(testCommand, browserTestCommand)
process.exit(code)
}

function executeTest (_command, _browserCommand) {
var node = spawn('npm', ['run', _command], { stdio: 'inherit' })
node.on('close', function (code) {
if (code === 0 && runBrowserTests && argv.browser) {
var browser = spawn('npm', ['run', _browserCommand], { stdio: 'inherit' })
browser.on('close', function (code) {
process.exit(code)
})
} else {
process.exit(code)
}
})
}
}
})
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.