Skip to content

Commit

Permalink
Add raw version of inspect-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Mar 10, 2017
1 parent ead2960 commit bd4acf8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
8 changes: 6 additions & 2 deletions test/fixtures/rawInspectLoader.js → lib/loader.raw.js
@@ -1,9 +1,13 @@
const inspectLoader = require("../../lib/loader");
"use strict";

const inspectLoader = require("./loader");

function rawInspectLoader() {
return inspectLoader.apply(this, arguments); // eslint-disable-line no-invalid-this
}

rawInspectLoader.raw = true;
Object.assign(rawInspectLoader, {
raw: true
}, inspectLoader);

module.exports = rawInspectLoader;
1 change: 1 addition & 0 deletions raw.js
@@ -0,0 +1 @@
module.exports = require("./lib/loader.raw");
27 changes: 27 additions & 0 deletions test/loader.raw.test.js
@@ -0,0 +1,27 @@
import test from "ava";
import compile from "./helpers/compile";
import rawInspectLoader from "../raw";
import inspectLoader from "../lib/loader";

test("should work the same as the inspect-loader just for buffers", t => {
const options = {
callback(i) {
inspect = i;
}
};
let inspect;

t.plan(1);

return compile([{
loader: require.resolve("../raw"),
options
}])
.then(() => {
t.true(inspect.arguments[0] instanceof Buffer);
});
});

test("should also expose the same callbacks object", t => {
t.is(inspectLoader.callbacks, rawInspectLoader.callbacks);
});
19 changes: 0 additions & 19 deletions test/loader.test.js
Expand Up @@ -146,22 +146,3 @@ test("should also work with webpack's loader context", t => {
t.is(inspect.options, options);
});
});

test("should be possible to make a raw loader", t => {
const options = {
callback(i) {
inspect = i;
}
};
let inspect;

t.plan(1);

return compile([{
loader: require.resolve("./fixtures/rawInspectLoader.js"),
options
}])
.then(() => {
t.true(inspect.arguments[0] instanceof Buffer);
});
});

0 comments on commit bd4acf8

Please sign in to comment.