Created
June 29, 2017 10:01
-
-
Save Saturate/243f68359f2f32ba4db5d16da002bed4 to your computer and use it in GitHub Desktop.
Convert Gulp 3 to Gulp 4 with a codemod
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
// Use https://astexplorer.net/ | |
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const root = j(file.source); | |
const gulpTaskCalls = root.find(j.CallExpression, { | |
callee: { | |
object: { | |
name: 'gulp' | |
}, | |
property: { | |
name: 'task' | |
} | |
} | |
}); | |
gulpTaskCalls.forEach(p => { | |
if(p.node.arguments[1].type == 'ArrayExpression') { | |
const dependentTasks = p.node.arguments[1]; | |
p.node.arguments[1] = j.callExpression( | |
j.identifier('gulp.series'), | |
dependentTasks.elements | |
); | |
} | |
}); | |
return root.toSource({quote: 'single'}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment