-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor migrate getTransformsForFile logic to mixed depper class
- Loading branch information
rubeniskov
committed
Nov 14, 2020
1 parent
877676c
commit 2b87d4c
Showing
4 changed files
with
127 additions
and
157 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
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,37 @@ | ||
/** | ||
* Gets glslify transform from given package.json | ||
* | ||
* @param {object|string} pkgJson package.json filename path or json | ||
* @returns {({tr: string, name: string, opts: object})[]} | ||
*/ | ||
const getTransformsFromPkg = (pkgJson) => { | ||
if (typeof pkgJson === 'string') { | ||
pkgJson = JSON.parse(pkgJson); | ||
} | ||
|
||
var transforms = ( | ||
pkgJson['glslify'] | ||
&& pkgJson['glslify']['transform'] | ||
|| [] | ||
) | ||
|
||
return transforms.map(function(key) { | ||
var transform = Array.isArray(key) | ||
? key | ||
: [key, {}] | ||
|
||
var key = transform[0] | ||
var opt = transform[1] | ||
|
||
if (opt) { | ||
delete opt.global | ||
delete opt.post | ||
} | ||
|
||
return { tr: key, opts: opt, name: key } | ||
}); | ||
} | ||
|
||
module.exports = { | ||
getTransformsFromPkg | ||
} |