Skip to content
Permalink
Browse files

bunch of cleanup so far

  • Loading branch information...
eoneill committed Oct 19, 2015
1 parent 3ad6578 commit f571a2bc03cf2e88e5767050b076268975e6c36d
@@ -1,2 +1,30 @@
/node_modules
/coverage
# Useless files
*.DS_Store

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
@@ -1,15 +1,10 @@
language: node_js
node_js:
- '0.12'
- '4'
#- iojs
env:
- COVERAGE=true
- COVERAGE=false
matrix:
exclude:
node_js: 'iojs'

- 0.12
- 4.0
- 4.1
- 4.2
- node
before_install:
- if [ $TRAVIS_OS_NAME == "linux" ]; then
export CC="gcc-4.7";
@@ -19,7 +14,6 @@ before_install:
fi
- gcc --version
- g++ --version

addons:
apt:
sources:
@@ -1,8 +1,8 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
pkg: grunt.file.readJSON("package.json")
});
grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks("grunt-release");

grunt.registerTask('default', []);
grunt.registerTask("default", []);
};

This file was deleted.

Oops, something went wrong.
@@ -5,7 +5,7 @@ var config = require("eyeglass-dev-eslint");

module.exports = function(gulp, depends) {
gulp.task("lint", depends, function() {
return gulp.src(["build/**/*.js", "lib/**/*.js", "test/**/*.js"])
return gulp.src(["*.js", "{build,lib,test}/**/*.js"])
.pipe(eslint(config))
.pipe(eslint.formatEach("stylish", process.stderr))
.pipe(eslint.failOnError());
@@ -1,12 +1,44 @@
"use strict";

var istanbul = require("gulp-istanbul");
var mocha = require("gulp-mocha");

var testSrc = "test/**/test_*.js";

module.exports = function(gulp, depends) {
gulp.task("test", depends, function() {
return gulp.src([
"test/**/test_*.js"
], {read: false})
.pipe(mocha({reporter: "spec"}));
function runTests() {
return gulp.src(testSrc, {
read: false
})
.pipe(mocha({
reporter: "spec"
}));
}

gulp.task("test", depends, function (cb) {
gulp.src(["*.js", "lib/**/*.js", "test/*.js"])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on("finish", function () {
runTests()
.pipe(istanbul.writeReports()) // Creating the reports after tests runned
.pipe(istanbul.enforceThresholds({
thresholds: {
global: {
statements: 95.05,
branches: 86.64,
functions: 97.14,
lines: 95.05
}
}
}))
.on("end", cb)
.on("error", function(e) {
console.error(e.toString());
process.exit(1);
});
});
});

gulp.task("test:uncovered", depends, runTests);
};
@@ -3,8 +3,7 @@ var gulp = require("gulp");
// Know the node-sass we wrap. It's vital to debugging, tests, and coverage reports
console.log(require("node-sass").info);

require("./build/lint")(gulp, []);
require("./build/lint")(gulp);
require("./build/test")(gulp, ["lint"]);
require("./build/coverage")(gulp, []);

gulp.task("default", ["test"]);
@@ -4,8 +4,8 @@ var fs = require("fs");
var fse = require("fs-extra");
var glob = require("glob");
var path = require("path");
var hash = require("./util/hash");
var unquote = require("./util/unquote");
var merge = require("lodash.merge");

// Returns whether a file exists.
function existsSync(file) {
@@ -37,10 +37,9 @@ function AssetPathEntry(srcPath, opts) {
this.httpPrefix = opts.httpPrefix || opts.name;
this.srcPath = srcPath;
this.pattern = opts.pattern || "**/*";
this.globOpts = {};
hash.merge(this.globOpts, this.defaultGlobOpts);
this.globOpts = merge({}, this.defaultGlobOpts);
if (opts.globOpts) {
hash.merge(this.globOpts, opts.globOpts);
this.globOpts = merge(this.globOpts, opts.globOpts);
}
this.globOpts.cwd = this.srcPath; // cannot be overridden by globOpts
this.globOpts.root = this.srcPath; // cannot be overridden by globOpts
@@ -2,7 +2,7 @@

var discover = require("./util/discover");
var syncFn = require("./util/sync_fn");
var hash = require("./util/hash");
var merge = require("lodash.merge");
var ARGUMENTS_REGEX = /\(.*\)$/;

function autoDiscoverModules(root) {
@@ -32,19 +32,19 @@ function checkConflicts(obj1, obj2) {

module.exports = function(eyeglass, sass, options, existingFunctions) {
var root = options.root;
var functions = {};
var modules = autoDiscoverModules(root);

modules.forEach(function(m) {
var obj = require(m)(eyeglass, sass);
var functions = modules.reduce(function(fns, mod) {
var obj = require(mod)(eyeglass, sass);
if (obj.functions) {
checkConflicts(functions, obj.functions);
hash.merge(functions, obj.functions);
checkConflicts(fns, obj.functions);
return merge(fns, obj.functions);
}
});
return fns;
}, {});

checkConflicts(functions, existingFunctions);
hash.merge(functions, existingFunctions);
functions = merge(functions, existingFunctions);

functions = syncFn.all(functions);

@@ -1,12 +1,12 @@
"use strict";

var hash = require("./util/hash");
var merge = require("lodash.merge");

module.exports = function(eyeglass, sass) {
var functions = {};
["asset_url", "version"].forEach(function(name) {
var fn = require("./functions/" + name)(eyeglass, sass);
hash.merge(functions, fn);
});
return functions;
return ["asset_url", "version"].reduce(function(functions, name) {
return merge(
functions,
require("./functions/" + name)(eyeglass, sass)
);
}, {});
};
@@ -3,30 +3,28 @@
var discover = require("../util/discover");
var unquote = require("../util/unquote");

// REFACTOR ME: this is copy pasta from module_importer.js
function eyeglassName(moduleDef) {
return (moduleDef.eyeglass &&
typeof moduleDef.eyeglass == "object" &&
moduleDef.eyeglass.name) ||
moduleDef.name;
}



module.exports = function(eyeglass, sass) {
return {
"eyeglass-version($module: eyeglass)": function(moduleName, done) {
var name = unquote(moduleName.getValue());
var modules = discover.all(eyeglass.root()).modules; // TODO Cache this value?
var mod;
for (var i = 0; i < modules.length; i++) {
if (eyeglassName(modules[i]) === name) {
mod = modules[i];
break;
}
var moduleDef;

// optimization if the name is `eyeglass` itself
if (name === "eyeglass") {
moduleDef = discover.getEyeglassDef();
} else {
// find the requested module
discover.all(eyeglass.root()).modules.some(function(mod) {
if (mod.eyeglassName === name) {
moduleDef = mod;
return true;
}
});
}
if (mod) {
done(sass.types.String('"' + (mod.version || "versonless") + '"'));

if (moduleDef) {
// TODO - why do we quote it?
done(sass.types.String('"' + (moduleDef.version || "unversioned") + '"'));
} else {
done(sass.types.Null());
}
@@ -33,6 +33,7 @@ ImportUtilities.prototype = {
},

getModuleByName: function(moduleName, dir) {
//console.log("[getModuleByName]", moduleName, dir);
var allModules = this.allModulesCache[dir];
if (!allModules) {
allModules = discover.all(dir, true, dir === this.root).modules;
@@ -2,8 +2,8 @@

var makeModuleImporter = require("./module_importer");
var makeAssetImporter = require("./assets_importer");
var customFunctions = require("./function_loader");
var hash = require("./util/hash");
var loadFunctions = require("./function_loader");
var merge = require("lodash.merge");
var engineChecks = require("./semver_checker");
var fs = require("fs");
var path = require("path");
@@ -47,13 +47,12 @@ Eyeglass.prototype = {
},
sassOptions: function() {
// TODO remove eyeglass specific options or maybe namespace them?
var opts = {};
hash.merge(opts, this.options);
var opts = merge({}, this.options);
opts.eyeglass = this;

var assetImporter = makeAssetImporter(this, this.sass, opts, opts.importer);
opts.importer = makeModuleImporter(this, this.sass, opts, assetImporter);
opts.functions = customFunctions(this, this.sass, opts, opts.functions);
opts.functions = loadFunctions(this, this.sass, opts, opts.functions);

return opts;
},
@@ -58,11 +58,17 @@ function makeImporter(eyeglass, sass, options, fallbackImporter) {

/*eslint-disable */
return function(uri, prev, done) {
//console.log("-----------------------------");
//console.log("[module_importer]", uri, prev);
var isRealFile = importUtils.existsSync(prev);
var fragments = uri.split("/");
var moduleName = fragments[0];
var relativePath = fragments.slice(1).join("/");
var pkgRootDir = isRealFile ? importUtils.packageRootDir(path.dirname(prev)) : root;
//console.log("[module_importer:isRealFile]", isRealFile);
//console.log("[module_importer:moduleName]", moduleName);
//console.log("[module_importer:relativePath]", relativePath);
//console.log("[module_importer:pkgRootDir]", pkgRootDir);
var jsFile = importUtils.getModuleByName(moduleName, pkgRootDir);

if (jsFile) {
Oops, something went wrong.

0 comments on commit f571a2b

Please sign in to comment.
You can’t perform that action at this time.