Skip to content

Commit

Permalink
Merge pull request #21 from austinpray/windoze
Browse files Browse the repository at this point in the history
Adds windoze compatibility
  • Loading branch information
austinpray committed Feb 26, 2015
2 parents 65b4909 + 6aba86d commit 26295fd
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
asset-builder
=============

[![Build Status](https://travis-ci.org/austinpray/asset-builder.svg?branch=master)](https://travis-ci.org/austinpray/asset-builder) [![Coverage Status](https://img.shields.io/coveralls/austinpray/asset-builder.svg?branch=master&style=flat)](https://coveralls.io/r/austinpray/asset-builder) [![Dependency Status](https://david-dm.org/austinpray/asset-builder.svg)](https://david-dm.org/austinpray/asset-builder) [![Code Climate](https://codeclimate.com/github/austinpray/asset-builder/badges/gpa.svg)](https://codeclimate.com/github/austinpray/asset-builder)
[![Build Status](https://travis-ci.org/austinpray/asset-builder.svg?branch=master)](https://travis-ci.org/austinpray/asset-builder) [![Build status](https://ci.appveyor.com/api/projects/status/grdwl6vflm7l68i6?svg=true)](https://ci.appveyor.com/project/austinpray/asset-builder) [![Coverage Status](https://img.shields.io/coveralls/austinpray/asset-builder.svg?branch=master&style=flat)](https://coveralls.io/r/austinpray/asset-builder) [![Dependency Status](https://david-dm.org/austinpray/asset-builder.svg)](https://david-dm.org/austinpray/asset-builder) [![Code Climate](https://codeclimate.com/github/austinpray/asset-builder/badges/gpa.svg)](https://codeclimate.com/github/austinpray/asset-builder)

Feed me a [manifest file](help/spec.md) and I will give you globs.

Expand Down
21 changes: 21 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Test against this version of Node.js
environment:
nodejs_version: "0.12"

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# install modules
- npm install

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm test

# Don't actually build.
build: off
5 changes: 4 additions & 1 deletion lib/buildGlobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var minimatch = require('minimatch');
var Dependency = require('./Dependency');
var types = require('./types.json');
var traverse = require('traverse');
var path = require('path');

/**
* buildGlobs
Expand Down Expand Up @@ -107,7 +108,9 @@ buildGlobs.prototype.filterByPackage = function(files, names, reject) {
}
return _[method](files, function(file) {
return _.some(names, function(name) {
return file.indexOf('/bower_components/' + name + '/') > -1;
return file.indexOf(
path.normalize('/bower_components/' + name + '/')
) > -1;
});
});
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asset-builder",
"version": "0.4.1",
"version": "1.0.0",
"description": "asset-builder =============",
"main": "index.js",
"scripts": {
Expand Down
47 changes: 28 additions & 19 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ var bower = require('bower');
var Q = require('q');
var mkdirp = require('mkdirp');
var _ = require('lodash');
var path = require('path');

function normalizeAll(files) {
return _.map(files, function(f) {
return path.normalize(f);
});
}

function bowerSetup(bowerJson) {
bowerJson = bowerJson || 'bower.json';
Expand Down Expand Up @@ -96,58 +103,60 @@ describe('Dependency', function () {
describe('Glob building', function () {
var manifest;
var mockBowerFiles = require('./fixtures/sampleMainBowerFiles.json').files;
mockBowerFiles = normalizeAll(mockBowerFiles);
var mockTypesFiles = require('./fixtures/types.json').files;
mockTypesFiles = normalizeAll(mockTypesFiles);
var globInstance = new buildGlobs(manifest, mockBowerFiles);
describe('filtering by package', function () {
it('should get particular package files by string', function () {
var jq = buildGlobs.prototype.filterByPackage(mockBowerFiles, 'jquery');
assert.isArray(jq);
assert.sameMembers(jq, [
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/jquery/dist/jquery.js",
path.normalize("/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/jquery/dist/jquery.js")
]);
});
it('should get particular package files by array', function () {
var jq = buildGlobs.prototype.filterByPackage(mockBowerFiles, ['jquery']);
assert.isArray(jq);
assert.sameMembers(jq, [
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/jquery/dist/jquery.js",
path.normalize("/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/jquery/dist/jquery.js")
]);
});
});

describe('rejecting by package', function () {
it('should return everything except specified packages', function () {
var rejected = buildGlobs.prototype.rejectByPackage([
var rejected = buildGlobs.prototype.rejectByPackage(normalizeAll([
'/bogus/bower_components/jquery/main.js',
'/bogus/bower_components/mootools/main.js'
], ['jquery']);
assert.sameMembers(rejected, [
]), ['jquery']);
assert.sameMembers(rejected, normalizeAll([
'/bogus/bower_components/mootools/main.js'
]);
]));
});
});

describe('filtering by type', function () {
it('should get fonts', function () {
assert.sameMembers(globInstance.filterByType(mockBowerFiles, 'fonts'), [
assert.sameMembers(globInstance.filterByType(mockBowerFiles, 'fonts'), normalizeAll([
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.eot",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.svg",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.ttf",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.woff"
]);
]));
});
it('should match woff2', function () {
assert.sameMembers(globInstance.filterByType(mockTypesFiles, 'fonts'), [
assert.sameMembers(globInstance.filterByType(mockTypesFiles, 'fonts'), normalizeAll([
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.eot",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.svg",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.ttf",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.woff",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.woff2",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/fonts/glyphicons-halflings-regular.otf"
]);
]));
});
it('should get javascript', function () {
assert.sameMembers(globInstance.filterByType(mockBowerFiles, 'js'), [
assert.sameMembers(globInstance.filterByType(mockBowerFiles, 'js'), normalizeAll([
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/jquery/dist/jquery.js",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/transition.js",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/alert.js",
Expand All @@ -161,12 +170,12 @@ describe('Glob building', function () {
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/scrollspy.js",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/tab.js",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/affix.js",
]);
]));
});
it('should get css', function () {
assert.sameMembers(globInstance.filterByType(mockBowerFiles, 'css'), [
assert.sameMembers(globInstance.filterByType(mockBowerFiles, 'css'), normalizeAll([
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/bogus/file.css"
]);
]));
});
});

Expand Down Expand Up @@ -223,11 +232,11 @@ describe('Glob building', function () {
});

describe('getting output files', function () {
var mockBower = [
var mockBower = normalizeAll([
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/jquery/dist/jquery.js",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/transition.js",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/alert.js",
];
]);
it('should add bower deps to the main dependency', function () {
var expected = [
{
Expand All @@ -251,16 +260,16 @@ describe('Glob building', function () {
type: 'js',
name: 'app.js',
globs: [
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/transition.js",
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/alert.js",
path.normalize("/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/transition.js"),
path.normalize("/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/bootstrap/js/alert.js"),
"path/to/script.js"
]
},
{
type: 'js',
name: 'jquery.js',
globs: [
"/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/jquery/dist/jquery.js",
path.normalize("/Users/austinpray/DEV/opensauce/asset-builder/test/tmp/bower_components/jquery/dist/jquery.js"),
]
}
];
Expand Down

0 comments on commit 26295fd

Please sign in to comment.