Skip to content

Commit e7ede11

Browse files
committed
Add failing glslify example
1 parent c47745a commit e7ede11

File tree

6 files changed

+43
-24
lines changed

6 files changed

+43
-24
lines changed

fixtures/glsl/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
const fs = require('fs')
2-
3-
console.log(fs.readFileSync(__dirname + '/package.json', 'utf8'))
2+
const glsl = require('glslify');
3+
const shader = glsl(fs.readFileSync(__dirname + '/shader.glsl', 'utf8'))

fixtures/glsl/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"name": "fixture",
33
"version": "1.0.0",
4-
"scripts": {
5-
"build": "../../node_modules/.bin/webpack"
6-
},
74
"browserify": {
85
"transform": [
96
"brfs",

fixtures/glsl/shader.glsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void main () { gl_Position = vec4(1); }

fixtures/glsl/webpack.config.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"tap-spec": "^4.1.1",
2828
"tape": "^4.4.0",
2929
"through2": "^2.0.0",
30-
"webpack": "^3.0.0"
30+
"webpack": "^3.4.0"
3131
},
3232
"scripts": {
3333
"test": "node test.js | tspec",

test.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const path = require('path')
55
const fs = require('fs')
66
const vm = require('vm')
77

8+
/*
89
test('ify-loader', function (t) {
910
const wpack = which.sync('webpack', { cwd: __dirname })
1011
const input = path.join(__dirname, 'fixtures', 'basic', 'index.js')
@@ -33,7 +34,8 @@ test('ify-loader', function (t) {
3334
log: function (src) {
3435
const expected = fs.readFileSync(pkg, { encoding: 'utf8' })
3536
t.equal(src, expected, 'processed brfs from package.json')
36-
}
37+
},
38+
error: console.error
3739
}
3840
})
3941
})
@@ -87,3 +89,39 @@ test('error handling', function (t) {
8789
t.equal(code, 2, 'exit code was 2')
8890
})
8991
})
92+
*/
93+
test('glsl-transform', function (t) {
94+
const wpack = which.sync('webpack', { cwd: __dirname })
95+
const input = path.join(__dirname, 'fixtures', 'glsl', 'index.js')
96+
const output = path.join(__dirname, 'fixtures', 'glsl', 'bundle.js')
97+
const pkg = path.join(__dirname, 'fixtures', 'glsl', 'package.json')
98+
99+
t.plan(1)
100+
101+
try {
102+
fs.unlinkSync(output)
103+
} catch (e) {}
104+
105+
spawn(wpack, [
106+
input,
107+
output,
108+
'--module-bind', 'js=' + __dirname
109+
], {
110+
stdio: ['pipe', 'pipe', 2]
111+
}).once('exit', function () {
112+
const result = fs.readFileSync(output, { encoding: 'utf8' })
113+
114+
fs.unlinkSync(output)
115+
116+
vm.runInNewContext(result, {
117+
console: {
118+
log: function (src) {
119+
const expected = fs.readFileSync(pkg, { encoding: 'utf8' })
120+
t.equal(src, expected, 'processed brfs from package.json')
121+
},
122+
error: console.error
123+
}
124+
})
125+
})
126+
})
127+

0 commit comments

Comments
 (0)