Skip to content

Commit 877676c

Browse files
author
rubeniskov
committed
refactor migrate readFile logic to mixed depper class
1 parent 1bd31d6 commit 877676c

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

depper.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ Depper.prototype.applyTransforms = function(filename, src, transforms, done) {
164164
}
165165
}
166166

167+
Depper.prototype.readFile = function(filename, done) {
168+
if (path.basename(filename) !== this._inlineName)
169+
return this._readFile(filename, done)
170+
171+
if(this._async) {
172+
return done(null, this._inlineSource)
173+
}
174+
return this._inlineSource
175+
}
176+
167177
function createDefaultRead(async) {
168178
if (async) {
169179
return function defaultRead(src, done) {

index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,6 @@ DepperAsync.prototype.add = function(filename, done) {
122122
}
123123
}
124124

125-
DepperAsync.prototype.readFile = function(filename, done) {
126-
if (path.basename(filename) !== this._inlineName)
127-
return this._readFile(filename, done)
128-
129-
return done(null, this._inlineSource)
130-
}
131-
132125
/**
133126
* Determines which transforms to use for a particular file.
134127
* The rules here are the same you see in browserify:

sync.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ DepperSync.prototype.add = function(filename) {
9898
}
9999
}
100100

101-
DepperSync.prototype.readFile = function(filename) {
102-
if (path.basename(filename) !== this._inlineName)
103-
return this._readFile(filename)
104-
105-
return this._inlineSource
106-
}
107-
108101
/**
109102
* Determines which transforms to use for a particular file.
110103
* The rules here are the same you see in browserify:

0 commit comments

Comments
 (0)