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

Feature/refactor add depper class mixed logic sync bt async #10

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
refactor migrate inline logic to mixed depper class
rubeniskov committed Nov 14, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8b5f7a9a669daed7a38f245f1fdd46369044b03d
14 changes: 14 additions & 0 deletions depper.js
Original file line number Diff line number Diff line change
@@ -49,6 +49,20 @@ function Depper(opts, async) {
}
}

Depper.prototype.inline = function(source, basedir, done) {
var inlineFile = path.resolve(basedir || this._cwd, this._inlineName)

this._inlineSource = source

if (this._async) {
this.add(inlineFile, function(err, tree) {
done && done(err, !err && tree)
})
} else {
return this.add(inlineFile)
}
}

function createDefaultRead(async) {
if (async) {
return function defaultRead(src, done) {
10 changes: 0 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -28,16 +28,6 @@ function DepperAsync(opts) {
Depper.call(this, opts, true);
}

DepperAsync.prototype.inline = function(source, basedir, done) {
var inlineFile = path.resolve(basedir || this._cwd, this._inlineName)

this._inlineSource = source

this.add(inlineFile, function(err, tree) {
done && done(err, !err && tree)
})
}

/**
* Adds a transform to use on your local dependencies.
* Note that this should be used before calling `add`.
8 changes: 0 additions & 8 deletions sync.js
Original file line number Diff line number Diff line change
@@ -26,14 +26,6 @@ function DepperSync(opts) {
Depper.call(this, opts)
}

DepperSync.prototype.inline = function(source, basedir) {
var inlineFile = path.resolve(basedir || this._cwd, this._inlineName)

this._inlineSource = source

return this.add(inlineFile)
}

/**
* Adds a transform to use on your local dependencies.
* Note that this should be used before calling `add`.