Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add ability to define output in RC file. Closes #1

  • Loading branch information...
commit 29cf025491a753d2b3702b9aafe62cd020384fb3 1 parent c3fca01
Jack Franklin authored
Showing with 28 additions and 15 deletions.
  1. +15 −6 README.md
  2. +1 −1  package.json
  3. +12 −8 pulldown.js
21 README.md
View
@@ -126,11 +126,16 @@ You can store dependencies within a local `.pulldownrc` file within your project
```
{
- "destination": "lib",
- "dependencies": [
- "jquery",
- "https://raw.github.com/wycats/handlebars.js/master/dist/handlebars.js"
- ]
+ "destination": "vendors",
+ "dependencies": [
+ {
+ "source": "jquery",
+ "output": "jquery.js"
+ },
+ {
+ "source": "https://raw.github.com/wycats/handlebars.js/1.0.rc.2/dist/handlebars.js"
+ }
+ ]
}
```
@@ -138,7 +143,7 @@ If you want the files to be downloaded to the same directory as the `.pulldownrc
The dependencies array can contain either names or URLs. If it contains a name (such as "jquery"), it will look in your `~/.pulldown.json` to find the URL. If the string is a URL, it will download it.
-Then when you run `pulldown` (without any arguments) within a directory that contains a `.pulldownrc`, it will download the dependencies for you.
+Then when you run `pulldown` (without any arguments) within a directory that contains a `.pulldownrc`, it will download the dependencies for you. If you don't define the `output` property for a dependency, pulldown will use the one in the source. For example, with the above handlebars dependency, it will be saved as `handlebars.js`.
## FAQs
@@ -151,6 +156,10 @@ It does, in that you can link to a specific version of a library. However it doe
## Changelog
+__V0.1.2__
+- updated structure of `.pulldownrc` to allow for specifying the file name
+- fix `mkdir` showing error if no directory given
+
__V0.1.1__
- if you try to install something to a folder that doesn't exist, pulldown will now create it
2  package.json
View
@@ -1,6 +1,6 @@
{
"name": "pulldown",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "Fetch popular web libraries from the net",
"preferGlobal": "true",
"bin": {
20 pulldown.js
View
@@ -17,7 +17,7 @@ reset = '\033[0m';
var pulldown = {
- VERSION: "0.1.1",
+ VERSION: "0.1.2",
packages: {},
userHome: function() {
return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
@@ -80,13 +80,15 @@ var pulldown = {
if(!isTest) console.log("-> " + green + "Found local .pulldownrc to download dependencies from", reset);
for(var i = 0; i < local.dependencies.length; i++) {
var nextDep = local.dependencies[i];
- if(nextDep.indexOf("http") > -1) {
- if(!isTest) console.log("-> " + "Downloading URL dependency: " + nextDep, reset);
- this.getFile(nextDep, (local.destination ? local.destination + "/" : "") + url.parse(nextDep).pathname.split('/').pop());
+ if(nextDep.source.indexOf("http") > -1) {
+ if(!isTest) console.log("-> " + "Downloading URL dependency: " + nextDep.source, reset);
+ output = ( nextDep.output === undefined ? url.parse(nextDep.source).pathname.split('/').pop() : nextDep.output);
+ console.log(output);
+ this.getFile(nextDep.source, (local.destination ? local.destination + "/" : "") + output);
} else {
- if(!isTest) console.log("-> " + "Downloading dependency: " + nextDep + " from ~/.pulldown.json", reset);
- var argResponse = this.parsePackageArgument(local.dependencies[i]);
- this.getFile(argResponse.url, (local.destination ? local.destination + "/" : "") + argResponse.output);
+ if(!isTest) console.log("-> " + "Downloading dependency: " + nextDep.source + " from ~/.pulldown.json", reset);
+ var argResponse = this.parsePackageArgument(local.dependencies[i].source);
+ this.getFile(argResponse.url, (local.destination ? local.destination + "/" : "") + nextDep.output || argResponse.output);
}
}
}
@@ -124,7 +126,9 @@ var pulldown = {
var slashOutput = output.split("/");
slashOutput.pop();
// make sure the folder exists
- shell.mkdir('-p', slashOutput.join("/"));
+ if(slashOutput.length > 0) {
+ shell.mkdir('-p', slashOutput.join("/"));
+ }
var requestOpts;
if(isZip) {
Please sign in to comment.
Something went wrong with that request. Please try again.