Skip to content
Advertisement

Use gulp files from other npm packages (import files which will eventually exist)

I have one npm package containing several files with several gulp task definitions.

What I want is in the main gulpfile, be able to copy these gulp files (from the package) and execute the gulp tasks defined in them.

Follows an example:

JavaScript

The problem is: When I try to execute gulp debug, it is retrieved an error saying require('../src/generated-code/gulp/gulp.debug') does not exists. And it is right because this file will be only available when the task copyGulpFiles is done.

Anyone knows a workaround to do what I want to accomplish?

Advertisement

Answer

The only workaround that I found was to combine fs.readFileSync and eval functions in order to read the gulp file content as a string and then evaluate that code in run time:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement