Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
chore(): cleanup dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tlancina committed Mar 31, 2016
1 parent 6bba171 commit d1aa3f3
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 136 deletions.
238 changes: 120 additions & 118 deletions lib/ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

var fs = require('fs'),
net = require('net'),
path = require('path'),
async = require('async');
path = require('path');

// for getPorts, which isn't used
// async = require('async');

// for getSocket, which isn't used
// mkdirp = require('mkdirp').mkdirp;
Expand Down Expand Up @@ -64,28 +66,28 @@ exports.getPort = function (options, callback) {
options.server.listen(options.port, options.host);
};

exports.getPorts = function (count, options, callback) {
if (!callback) {
callback = options;
options = {};
}

var lastPort = null;
async.timesSeries(count, function(index, asyncCallback) {
if (lastPort) {
options.port = exports.nextPort(lastPort);
}

exports.getPort(options, function (err, port) {
if (err) {
asyncCallback(err);
} else {
lastPort = port;
asyncCallback(null, port);
}
});
}, callback);
};
// exports.getPorts = function (count, options, callback) {
// if (!callback) {
// callback = options;
// options = {};
// }
//
// var lastPort = null;
// async.timesSeries(count, function(index, asyncCallback) {
// if (lastPort) {
// options.port = exports.nextPort(lastPort);
// }
//
// exports.getPort(options, function (err, port) {
// if (err) {
// asyncCallback(err);
// } else {
// lastPort = port;
// asyncCallback(null, port);
// }
// });
// }, callback);
// };

//
// ### function getSocket (options, callback)
Expand All @@ -94,86 +96,86 @@ exports.getPorts = function (count, options, callback) {
// Responds with a unbound socket using the specified directory and base
// name on the current machine.
//
exports.getSocket = function (options, callback) {
if (!callback) {
callback = options;
options = {};
}

options.mod = options.mod || 0755;
options.path = options.path || exports.basePath + '.sock';

//
// Tests the specified socket
//
function testSocket () {
fs.stat(options.path, function (err) {
//
// If file we're checking doesn't exist (thus, stating it emits ENOENT),
// we should be OK with listening on this socket.
//
if (err) {
if (err.code == 'ENOENT') {
callback(null, options.path);
}
else {
callback(err);
}
}
else {
//
// This file exists, so it isn't possible to listen on it. Lets try
// next socket.
//
options.path = exports.nextSocket(options.path);
exports.getSocket(options, callback);
}
});
}

//
// Create the target `dir` then test connection
// against the socket.
//
function createAndTestSocket (dir) {
mkdirp(dir, options.mod, function (err) {
if (err) {
return callback(err);
}

options.exists = true;
testSocket();
});
}

//
// Check if the parent directory of the target
// socket path exists. If it does, test connection
// against the socket. Otherwise, create the directory
// then test connection.
//
function checkAndTestSocket () {
var dir = path.dirname(options.path);

fs.stat(dir, function (err, stats) {
if (err || !stats.isDirectory()) {
return createAndTestSocket(dir);
}

options.exists = true;
testSocket();
});
}

//
// If it has been explicitly stated that the
// target `options.path` already exists, then
// simply test the socket.
//
return options.exists
? testSocket()
: checkAndTestSocket();
};
// exports.getSocket = function (options, callback) {
// if (!callback) {
// callback = options;
// options = {};
// }
//
// options.mod = options.mod || 0755;
// options.path = options.path || exports.basePath + '.sock';
//
// //
// // Tests the specified socket
// //
// function testSocket () {
// fs.stat(options.path, function (err) {
// //
// // If file we're checking doesn't exist (thus, stating it emits ENOENT),
// // we should be OK with listening on this socket.
// //
// if (err) {
// if (err.code == 'ENOENT') {
// callback(null, options.path);
// }
// else {
// callback(err);
// }
// }
// else {
// //
// // This file exists, so it isn't possible to listen on it. Lets try
// // next socket.
// //
// options.path = exports.nextSocket(options.path);
// exports.getSocket(options, callback);
// }
// });
// }
//
// //
// // Create the target `dir` then test connection
// // against the socket.
// //
// function createAndTestSocket (dir) {
// mkdirp(dir, options.mod, function (err) {
// if (err) {
// return callback(err);
// }
//
// options.exists = true;
// testSocket();
// });
// }
//
// //
// // Check if the parent directory of the target
// // socket path exists. If it does, test connection
// // against the socket. Otherwise, create the directory
// // then test connection.
// //
// function checkAndTestSocket () {
// var dir = path.dirname(options.path);
//
// fs.stat(dir, function (err, stats) {
// if (err || !stats.isDirectory()) {
// return createAndTestSocket(dir);
// }
//
// options.exists = true;
// testSocket();
// });
// }
//
// //
// // If it has been explicitly stated that the
// // target `options.path` already exists, then
// // simply test the socket.
// //
// return options.exists
// ? testSocket()
// : checkAndTestSocket();
// };

//
// ### function nextPort (port)
Expand All @@ -191,17 +193,17 @@ exports.nextPort = function (port) {
// Gets the next socket path in sequence from the
// specified `socketPath`.
//
exports.nextSocket = function (socketPath) {
var dir = path.dirname(socketPath),
name = path.basename(socketPath, '.sock'),
match = name.match(/^([a-zA-z]+)(\d*)$/i),
index = parseInt(match[2]),
base = match[1];

if (isNaN(index)) {
index = 0;
}

index += 1;
return path.join(dir, base + index + '.sock');
};
// exports.nextSocket = function (socketPath) {
// var dir = path.dirname(socketPath),
// name = path.basename(socketPath, '.sock'),
// match = name.match(/^([a-zA-z]+)(\d*)$/i),
// index = parseInt(match[2]),
// base = match[1];
//
// if (isNaN(index)) {
// index = 0;
// }
//
// index += 1;
// return path.join(dir, base + index + '.sock');
// };
7 changes: 4 additions & 3 deletions lib/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var fs = require('fs'),
serveStatic = require('serve-static'),
tinylr = require('tiny-lr-fork'),
lr = require('connect-livereload'),
vfs = require('vinyl-fs'),
globWatch = require('glob-watcher'),
request = require('request'),
proxyMiddleware = require('proxy-middleware'),
url = require('url'),
Expand Down Expand Up @@ -268,9 +268,10 @@ Serve.runLivereload = function runLivereload(options, app) {

// log.debug('Absolute watch paths:', absoluteWatchPaths);

vfs.watch(options.watchPatterns, {}, function(f) {
var watcher = globWatch(options.watchPatterns);
watcher.on('change', function(evt){
//TODO: Move prototype to Serve._changed
Serve._changed(f.path, options);
Serve._changed(evt.path, options);
});

var liveReloadPort = process.env.CONNECT_LIVE_RELOAD_PORT || options.liveReloadPort;
Expand Down
4 changes: 1 addition & 3 deletions lib/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var fs = require('fs'),
colors = require('colors'),
Q = require('q'),
open = require('open'),
unzip = require('unzip'),
unzip = require('unzip2'),
xml2js = require('xml2js'),
ProgressBar = require('progress'),
IonicProject = require('./project'),
Expand Down Expand Up @@ -273,8 +273,6 @@ Start.loadAppSetup = function loadAppSetup(options) {

//Not Tested
Start.fetchCreatorApp = function(options) {
var unzip = require('unzip2');

var cookies = new IonicStore('cookies').get('https://apps.ionic.io');

var sessionId;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Utils.fetchArchive = function fetchArchive(targetPath, archiveUrl, isGui) {
var os = require('os');
var fs = require('fs');
var path = require('path');
var unzip = require('unzip');
var unzip = require('unzip2');
var q = Q.defer();

// The folder name the project will be downloaded and extracted to
Expand Down
12 changes: 1 addition & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,18 @@
"license": "MIT",
"dependencies": {
"archiver": "0.5.2",
"async": "0.9.0",
"autoprefixer": "6.2.3",
"cheerio": "0.19.0",
"colors": "0.6.2",
"connect": "3.1.1",
"connect-livereload": "0.5.2",
"cordova-lib": "6.1.0",
"crc": "3.2.1",
"cross-spawn-async": "2.1.9",
"event-stream": "3.0.20",
"finalhandler": "0.2.0",
"form-data": "0.1.4",
"gulp-autoprefixer": "3.1.0",
"gulp-cached": "1.1.0",
"gulp-sass": "2.1.1",
"gulp-watch": "4.3.5",
"lodash": "3.10.1",
"glob-watcher": "2.0.0",
"open": "0.0.5",
"optimist": "0.6.0",
"postcss": "5.0.14",
"progress": "1.1.7",
"prompt": "0.2.12",
"proxy-middleware": "0.7.0",
Expand All @@ -72,9 +64,7 @@
"shelljs": "0.2.6",
"tiny-lr-fork": "0.0.5",
"underscore": "1.7.0",
"unzip": "0.1.9",
"unzip2": "0.2.5",
"vinyl-fs": "1.0.0",
"winston": "1.1.2",
"xml2js": "0.4.16"
},
Expand Down

0 comments on commit d1aa3f3

Please sign in to comment.