Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export only the browserify transform by default, allowing for webpack… #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"rules": {
"indent": [
2,
4
],
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
]
},
"env": {
"node": true,
"browser": true
},
"extends": "eslint:recommended"
}
14 changes: 4 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@ var glslunit = require('./lib/glsl-compiler'),
fs = require('fs'),
path = require('path'),
falafel = require('falafel'),
path = require('path'),
callerPath = require('caller-path');

module.exports = function(a, b) {
var base = callerPath();
if (base.match(new RegExp('node_modules\\' + path.sep + 'browserify'))) {
return browserify(a);
} else {
return node(a, b, base);
}
};
module.exports = browserify;
module.exports.node = node;

function browserify(file) {
var data = '',
Expand Down Expand Up @@ -63,7 +56,8 @@ function browserify(file) {
return stream;
}

function node(filePath, prepend, base) {
function node(filePath, prepend) {
var base = callerPath();
var fragmentPath = path.resolve(base, '..', filePath.replace('.*.', '.fragment.')),
fragment = fs.readFileSync(fragmentPath, 'utf8'),
vertexPath = path.resolve(base, '..', filePath.replace('.*.', '.vertex.')),
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"devDependencies": {
"browserify": "~3.38.0",
"concat-stream": "~1.4.4",
"eslint": "^1.8.0",
"tap": "~0.4.8"
},
"keywords": [
Expand All @@ -28,6 +29,6 @@
"url": "git@github.com:mapbox/glify.git"
},
"scripts": {
"test": "tap test/*.js"
"test": "eslint index.js && tap test/*.js"
}
}
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ test('browserified glify', function(t) {
});

test('nodeified glify', function(t) {
t.deepEqual(glify('../example/fill.*.glsl'), result);
t.deepEqual(glify.node('../example/fill.*.glsl'), result);
t.end();
});