Skip to content

Instantly share code, notes, and snippets.

@Saturate
Created June 29, 2017 10:01
Show Gist options
  • Save Saturate/243f68359f2f32ba4db5d16da002bed4 to your computer and use it in GitHub Desktop.
Save Saturate/243f68359f2f32ba4db5d16da002bed4 to your computer and use it in GitHub Desktop.
Convert Gulp 3 to Gulp 4 with a codemod
// 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