Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
4,174 additions
and
20,220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import path from 'path'; | ||
|
||
const pluginExist = (pluginPath) => { | ||
try { | ||
require(pluginPath); | ||
return true; | ||
} catch {} | ||
|
||
return false; | ||
} | ||
|
||
export default (pluginName, root = './') => { | ||
if (pluginExist(pluginName)) { | ||
return pluginName; | ||
} | ||
|
||
const pluginResolvePath = path.resolve(path.join(root, pluginName)); | ||
if (pluginExist(pluginResolvePath)) { | ||
return pluginResolvePath; | ||
} | ||
|
||
return pluginName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = function (options) { | ||
return function (tree) { | ||
return tree; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import path from 'path'; | ||
import test from 'ava'; | ||
import pluginResolve from '../src/plugin-resolve'; | ||
|
||
test('should return function', t => { | ||
t.true(typeof pluginResolve === 'function'); | ||
}); | ||
|
||
test('should return node_modules module path', t => { | ||
const pluginName = 'posthtml-custom-elements'; | ||
const pluginPath = pluginResolve(pluginName); | ||
t.is(pluginPath, pluginName); | ||
}); | ||
|
||
test('should return custom module path', t => { | ||
const pluginName = 'test/plugins/custom-plugin.js'; | ||
const pluginPath = pluginResolve(pluginName); | ||
t.is(pluginPath, path.resolve(path.join('./', pluginName))); | ||
}); |