Skip to content

Commit 9feb80c

Browse files
authored
remove filePathFromLoader (#26)
1 parent 41db697 commit 9feb80c

4 files changed

Lines changed: 1 addition & 34 deletions

File tree

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ With it initialized, you can use any of the following functions:
4040
- `util.pathsToRegex(paths)` - given an array of file paths, builds a regex that will match only those paths
4141
- `util.modifyOutputPath(file, outPath)` - Given an absolute or relative (to the project root) path to a file that's being processed by spike, changes the output path to absolute or relative (recommended) path provided. Recommended to use in the `emit` plugin stage.
4242

43-
And some static methods:
44-
- `SpikeUtils.filePathFromLoader(loaderContext)` - pass `this` inside a loader and it will return a file object with the absolute and relative paths to the current file being processed.
45-
4643
For more details on any given function, check out the source! I would never say this for any other library, but this is only one simple file, with fairly small functions that are extremely thoroughly documented, so I think it's worth jumping in.
4744

4845
### License & Contributing

lib/index.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,4 @@ module.exports = class SpikeUtils {
166166
return p.replace(/\//g, '\\/')
167167
}).join('|'))
168168
}
169-
170-
/**
171-
* Given a loader context, resolves the path of the current file and returns
172-
* a `File` object containing both the absolute and relative paths.
173-
* @param {Object} context - `this` from a webpack loader
174-
* @return {File} file object containing absolute and relative paths
175-
*/
176-
static filePathFromLoader (loaderContext) {
177-
const f = url.parse(loaderContext.request.split('!').slice(-1)[0]).pathname
178-
return new File(loaderContext.options.context, f)
179-
}
180169
}

test/index.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const path = require('path')
33
const fs = require('fs')
44
const Spike = require('spike-core')
55
const TestPlugin = require('./plugin')
6-
const EventEmitter = require('events')
76

87
const fixtures = path.join(__dirname, 'fixtures')
98

@@ -12,9 +11,8 @@ test.cb('EVERYTHING WORKS', (t) => {
1211
const plugin = new TestPlugin({
1312
injectFile: path.join(fixturePath, 'views/index.txt')
1413
})
15-
const loaderEmitter = new EventEmitter()
1614

17-
t.plan(12)
15+
t.plan(10)
1816

1917
plugin.on('addFilesAsWebpackEntries', (comp) => {
2018
const mod = comp.modules.find((m) => m.rawRequest === './views/index.txt')
@@ -36,19 +34,9 @@ test.cb('EVERYTHING WORKS', (t) => {
3634
t.falsy(p.absolute.match('public'))
3735
})
3836

39-
loaderEmitter.on('filePathFromLoader', (f) => {
40-
t.regex(f.absolute, /basic\/views\/index.txt/)
41-
t.truthy(f.relative === 'views/index.txt')
42-
})
43-
4437
const project = new Spike({
4538
root: fixturePath,
4639
entry: { main: ['./entry.js'] },
47-
resolveLoader: { alias: { test: path.join(__dirname, 'loader.js') } },
48-
module: {
49-
loaders: [{ test: /\.txt$/, loader: 'source!test', skipSpikeProcessing: true }]
50-
},
51-
loaderEmitter: loaderEmitter,
5240
ignore: ['**/views/ignoreme.txt'],
5341
plugins: [plugin],
5442
devtool: 'source-map'

test/loader.js

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

0 commit comments

Comments
 (0)