Browse files

used `path.join` to make it more cross-platform

  • Loading branch information...
1 parent b5fb4bf commit 05c2ba34512ccd9a96e6856828fd0c65e9a80701 @fent fent committed Mar 4, 2012
Showing with 18 additions and 20 deletions.
  1. +2 −2 example/download.js
  2. +2 −2 example/info.js
  3. +2 −4 lib/youtube-dl.js
  4. +1 −1 scripts/download.js
  5. +7 −7 test/download.js
  6. +4 −4 test/info.js
View
4 example/download.js
@@ -1,7 +1,7 @@
-youtubedl = require('..');
+var ytdl = require('..');
-dl = youtubedl.download('http://www.youtube.com/watch?v=90AiXO1pAiA',
+dl = ytdl.download('http://www.youtube.com/watch?v=90AiXO1pAiA',
__dirname,
// optional arguments passed to youtube-dl
['--max-quality=18']);
View
4 example/info.js
@@ -1,6 +1,6 @@
-youtube = require('..');
+var ytdl = require('..');
-youtube.info('http://www.youtube.com/watch?v=WKsjaOqDXgg',
+ytdl.info('http://www.youtube.com/watch?v=WKsjaOqDXgg',
// called when video page is downloaded and info extracted
function(err, info) {
View
6 lib/youtube-dl.js
@@ -32,7 +32,7 @@ var parseOpts = function(args) {
};
// check that youtube-dl file exists
-var file = path.normalize(__dirname + '/../bin/youtube-dl');
+var file = path.join(__dirname, '..', 'bin', 'youtube-dl');
path.exists(file, function(exists) {
if (exists) return;
@@ -117,9 +117,7 @@ var regex = /(\d+\.\d)% of (\d+\.\d+\w) at\s+([^\s]+) ETA ((\d|-)+:(\d|-)+)/;
// main download function
exports.download = function(url, dest, args) {
// setup settings
- if (dest == null) {
- dest = './';
- }
+ dest = dest || process.cwd();
if (args == null) {
args = [];
} else {
View
2 scripts/download.js
@@ -4,7 +4,7 @@ var fs = require('fs')
, exec = require('child_process').exec
-var folder = path.normalize(__dirname + '/../bin')
+var folder = path.join(__dirname, '..', 'bin')
, filename = '/youtube-dl'
, filepath = folder + filename
View
14 test/download.js
@@ -1,9 +1,9 @@
-var vows = require('vows')
- ytdl = require('..'),
- fs = require('fs'),
- path = require('path'),
- assert = require('assert'),
- video = 'http://www.youtube.com/watch?v=90AiXO1pAiA';
+var vows = require('vows')
+ , ytdl = require('..')
+ , fs = require('fs')
+ , path = require('path')
+ , assert = require('assert')
+ , video = 'http://www.youtube.com/watch?v=90AiXO1pAiA'
vows.describe('download').addBatch({
@@ -35,7 +35,7 @@ vows.describe('download').addBatch({
'file was downloaded': function(err, data) {
// check existance
- var filepath = __dirname + '/' + data.filename;
+ var filepath = path.join(__dirname, data.filename);
assert.isTrue(path.existsSync(filepath));
// delete file after each test
View
8 test/info.js
@@ -1,7 +1,7 @@
-var vows = require('vows')
- ytdl = require('./../lib/youtube-dl'),
- assert = require('assert'),
- video = 'http://www.youtube.com/watch?v=90AiXO1pAiA';
+var vows = require('vows')
+ , ytdl = require('..')
+ , assert = require('assert')
+ , video = 'http://www.youtube.com/watch?v=90AiXO1pAiA'
vows.describe('info').addBatch({

0 comments on commit 05c2ba3

Please sign in to comment.