Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First go at a CLI tool

  • Loading branch information...
commit 9e824564c799b360bf04f1e78344f53341dc9aa5 1 parent 09bb149
@chrisjpowers authored
View
54 bin/cli.js
@@ -0,0 +1,54 @@
+#!/usr/bin/env node
+
+var token,
+ drop,
+ pathLib = require('path'),
+ AirDrop = require(pathLib.join(__dirname, "..", "lib", "air-drop.js")),
+ package = require(pathLib.join(__dirname, "..", "package.json"));
+
+if (process.argv.indexOf("-v") > -1) {
+ console.log(package.version);
+ process.exit();
+}
+
+if (process.argv.indexOf("--css") > -1) {
+ drop = AirDrop("main.css");
+} else {
+ drop = AirDrop("main.js");
+}
+
+if (process.argv.indexOf("--minimize") > -1) drop.minimize();
+
+drop.package();
+
+while (token = process.argv.shift()) {
+ if (token === "--include" || token === "-i") {
+ drop.include(process.argv.shift());
+ }
+ else if (token === "--require" || token === "-r") {
+ drop.require(process.argv.shift());
+ }
+ else if (token === "--strip-function" || token === "-s") {
+ drop.stripFunction(process.argv.shift());
+ }
+}
+
+var trySource = function() {
+ setTimeout(function() {
+ if (drop.paths.length > 0) {
+ drop.source(function(err, source) {
+ if (err) {
+ process.stderr.write("Error: " + err);
+ }
+ else {
+ process.stdout.write(source);
+ }
+ });
+ }
+ else {
+ trySource();
+ }
+ }, 1000);
+}
+
+trySource();
View
5 package.json
@@ -1,12 +1,15 @@
{
"name": "air-drop",
- "version": "0.2.1",
+ "version": "0.2.2",
"author": "Chris Powers <chrisjpowers@gmail.com>",
"description": "Utility for packaging, manipulating and delivering JS and CSS source to the browser",
"scripts": {
"test": "jasmine-node --coffee spec"
},
"main": "./lib/air-drop.js",
+ "bin": {
+ "air-drop": "bin/cli.js"
+ },
"dependencies": {
"async": "*",
"connect": "> 2.0.0",
View
3  spec/fixtures/modules/module-a/package.json
@@ -1,3 +1,4 @@
{
-
+ "name": "module-a",
+ "version": "0.0.1"
}
View
2  spec/fixtures/modules/module-b/package.json
@@ -1,3 +1,5 @@
{
+ "name": "module-b",
+ "version": "0.0.1",
"main": "./lib/module-b"
}
View
2  spec/fixtures/modules/module-c/package.json
@@ -1,3 +1,5 @@
{
+ "name": "module-c",
+ "version": "0.0.1",
"main": "main"
}
Please sign in to comment.
Something went wrong with that request. Please try again.