Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed symlink installation issue

  • Loading branch information...
commit 68199c06f473ebe88af1ef84ea111747589a43e6 1 parent d05b14c
@fent fent authored
View
1  .gitignore
@@ -1,2 +1 @@
-bin
*.mp4
View
1  .npmignore
@@ -1,2 +1 @@
-bin
*.mp4
View
2  README.md
@@ -81,7 +81,7 @@ Install
npm install youtube-dl
-This will install this node module along with the latest version of [youtube-dl][] into your module folder. It will also create a symlink to youtube-dl so you run it from the command line.
+This will install this node module along with the latest version of [youtube-dl][] into your module folder. Use the -g option on the npm install command to install globally and add a symlink to youtube-dl so it can be used in command line.
### API Change
View
3,765 bin/youtube-dl
3,765 additions, 0 deletions not shown
View
8 package.json
@@ -2,7 +2,7 @@
"name": "youtube-dl",
"description": "youtube-dl driver for node",
"keywords": ["youtube", "download"],
- "version": "1.1.1",
+ "version": "1.1.2",
"homepage": "https://github.com/fent/node-youtube-dl",
"repository": {
"type": "git",
@@ -10,13 +10,13 @@
},
"author": "Roly Fentanes (https://github.com/fent)",
"main": "./lib/youtube-dl.js",
+ "bin": "./bin/youtube-dl",
"directories": {
"lib": "./lib"
},
"scripts": {
- "preinstall": "node ./scripts/download.js",
- "update": "node ./scripts/download.js",
- "preuninstall": "node ./scripts/download.js"
+ "install": "node ./scripts/download.js",
+ "update": "node ./scripts/download.js"
},
"engines": {
"node": "*"
View
61 scripts/download.coffee
@@ -9,48 +9,25 @@ exec = require('child_process').exec
folder = path.normalize __dirname + '/../bin'
filename = '/youtube-dl'
filepath = folder + filename
-symlink = path.dirname(process.env._) + filename
-
-
-# removes symlink only if it exists
-removeLink = ->
- linkExists = (try
- fs.readlinkSync symlink
- true
- catch err
- false
- )
- if linkExists
- fs.unlinkSync symlink
# download youtube-dl
-switch process.env.npm_lifecycle_event
- when 'preinstall', 'update'
- https.get({
- host: 'raw.github.com',
- path: '/rg3/youtube-dl/master/youtube-dl'
- }, (res) ->
- content = ''
- res.on 'data', (data) ->
- content += data
-
- res.on 'end', () ->
- # make bin folder if not exists
- if not path.existsSync folder
- fs.mkdirSync folder, 0744
-
- # remove symlink if it exists
- removeLink()
-
- # write, chdmod, and symlink file when finished
- fs.writeFileSync filepath, content
- fs.chmodSync filepath, 0711
- fs.symlinkSync filepath, symlink
-
- ).on 'error', (err) ->
- throw err
-
- when 'preuninstall'
- # remove symlink
- removeLink()
+https.get({
+ host: 'raw.github.com',
+ path: '/rg3/youtube-dl/master/youtube-dl'
+}, (res) ->
+ content = ''
+ res.on 'data', (data) ->
+ content += data
+
+ res.on 'end', () ->
+ # make bin folder if not exists
+ if not path.existsSync folder
+ fs.mkdirSync folder, 0744
+
+ # write file when finished
+ fs.writeFileSync filepath, content
+ fs.chmodSync filepath, 0711
+
+).on 'error', (err) ->
+ throw err
View
62 scripts/download.js
@@ -1,5 +1,5 @@
(function() {
- var exec, filename, filepath, folder, fs, https, path, removeLink, symlink;
+ var exec, filename, filepath, folder, fs, https, path;
fs = require('fs');
path = require('path');
https = require('https');
@@ -7,47 +7,23 @@
folder = path.normalize(__dirname + '/../bin');
filename = '/youtube-dl';
filepath = folder + filename;
- symlink = path.dirname(process.env._) + filename;
- removeLink = function() {
- var linkExists;
- linkExists = ((function() {
- try {
- fs.readlinkSync(symlink);
- return true;
- } catch (err) {
- return false;
+ https.get({
+ host: 'raw.github.com',
+ path: '/rg3/youtube-dl/master/youtube-dl'
+ }, function(res) {
+ var content;
+ content = '';
+ res.on('data', function(data) {
+ return content += data;
+ });
+ return res.on('end', function() {
+ if (!path.existsSync(folder)) {
+ fs.mkdirSync(folder, 0744);
}
- })());
- if (linkExists) {
- return fs.unlinkSync(symlink);
- }
- };
- switch (process.env.npm_lifecycle_event) {
- case 'preinstall':
- case 'update':
- https.get({
- host: 'raw.github.com',
- path: '/rg3/youtube-dl/master/youtube-dl'
- }, function(res) {
- var content;
- content = '';
- res.on('data', function(data) {
- return content += data;
- });
- return res.on('end', function() {
- if (!path.existsSync(folder)) {
- fs.mkdirSync(folder, 0744);
- }
- removeLink();
- fs.writeFileSync(filepath, content);
- fs.chmodSync(filepath, 0711);
- return fs.symlinkSync(filepath, symlink);
- });
- }).on('error', function(err) {
- throw err;
- });
- break;
- case 'preuninstall':
- removeLink();
- }
+ fs.writeFileSync(filepath, content);
+ return fs.chmodSync(filepath, 0711);
+ });
+ }).on('error', function(err) {
+ throw err;
+ });
}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.