Gulp Build command is failing with error " EISDIR: Illegal operation on directory" - gulp

I am trying to run the gulp build task for the dev environment on the server but its failing. However, The same gulp build is working on my local machine. The function and error are given below.
Function:
// S3 Upload for dev
gulp.task('s3sync:dev', function () {
var config = {
accessKeyId: "-Key-",
secretAccessKey: "-Key-"
};
var s3 = require('gulp-s3-upload')(config);
return gulp.src("./dist/**")
.pipe(s3({
Bucket: 'example',
ACL: 'public-read'
}, {
maxRetries: 5
}))
});
Command:
Gulp build:development
Error:
[09:01:04] Starting 's3sync:dev'...
events.js:160
throw er; // Unhandled 'error' event
^
Error: EISDIR: illegal operation on a directory, read
at Error (native)
Any idea?

Finally, This problem has been solved by removing a system symlink which was created after the deployment from the capistrano which is also running below npm commands.
npm run clean && npm run build
After removing the system file. I have run the below command and it works fine.
gulp build:development

Related

Getting "includes is not a function" in Gulp

I'm new to Gulp. I wrote a function to parse the version in my package.json file like this
// Get the semver part of the version, e.g.,
// version = 1.4.31-p2, should return 1.4.31
function getSemVer(cb) {
var semVer = pkg.version;
if (semVer.includes("-")) {
semVer = semVer.split("-")[0];
}
console.log(semVer);
cb();
}
exports.getSemVer = getSemver
But when I run this I get an error
$ gulp getSemver -f gulpfiles/version.js
[22:56:58] Working directory changed to /path/gulpfiles
[22:56:59] Using gulpfile /path/gulpfiles/version.js
[22:56:59] Starting 'getSemVer'...
[22:56:59] 'getSemVer' errored after 1.53 ms
[22:56:59] TypeError: semVer.includes is not a function
at getSemVer (/path/gulpfiles/version.js:27:14)
at taskWrapper (/path/node_modules/undertaker/lib/set-task.js:13:15)
at bound (node:domain:416:15)
at runBound (node:domain:427:12)
at asyncRunner (/path/node_modules/async-done/index.js:55:18)
at processTicksAndRejections (node:internal/process/task_queues:78:11)
I thought includes() a valid JavaScript function, shown in JavaScript String includes(). What gives?

TypeError: dest.on is not a function in gulp

When I edit theme .yml files in my themes source folder, I get this error. This does not happen when I edit scss or template .yml files from the template folder, only in the main folder. Others that had this error use things like webpack what I don't have. The gulp task for copy_theme_files is the same as other tasks with the difference that it has no return because I didn't know how to return there with two gulp.src functions.
gulp.task('copy_theme_files', function() {
console.log('[copy_theme_files] Console Log: copy '+paths.themeSrc+' to '+paths.themeDest);
gulp.src(paths.themeSrc)
.pipe(gulp.dest(paths.themeDest));
gulp.src(paths.root + '/*.{png,ico,svg}')
.pipe(paths.themeDest);
});
Full gulpfile.js https://pastebin.com/NWt2uMwV
Error Output:
[00:37:58] Using gulpfile /var/www/themes.src/mytheme.src/gulpfile.js
[00:37:58] Starting 'watch'...
[00:38:20] Starting 'copy_theme_files'...
[copy_theme_files] Console Log: copy *.{yml,theme,php,png,jpg,gif,svg,ico},.gitkeep to build
[00:38:20] 'copy_theme_files' errored after 23 ms
[00:38:20] TypeError: dest.on is not a function
at DestroyableTransform.Readable.pipe (/var/www/themes.src/mytheme.src/node_modules/readable-stream/lib/_stream_readable.js:564:8)
at /var/www/themes.src/mytheme.src/gulpfile.js:122:10
at taskWrapper (/var/www/themes.src/mytheme.src/node_modules/undertaker/lib/set-task.js:13:15)
at bound (domain.js:395:14)
at runBound (domain.js:408:12)
at asyncRunner (/var/www/themes.src/mytheme.src/node_modules/async-done/index.js:55:18)
at process._tickCallback (internal/process/next_tick.js:61:11)
[00:38:20] Starting 'copy_includes'...
[copy_includes] Console Log: copy includes/**/*.*,includes/**/.gitkeep to build/includes
[00:38:20] Finished 'copy_includes' after 7.41 ms
[00:38:20] Starting 'copy_build'...
[copy_build] Console Log: copy build/**/*.*,build/**/.gitkeep to ../../web/themes/local/mytheme
[00:38:20] Finished 'copy_build' after 60 ms
Other tasks run fine
[00:41:06] Starting 'copy_templates'...
[copy_templates] Console Log: copy templates/**/*.twig,templates/**/.gitkeep to build/templates
[00:41:08] Finished 'copy_templates' after 1.86 s
[00:41:08] Starting 'copy_build'...
[copy_build] Console Log: copy build/**/*.*,build/**/.gitkeep to ../../web/themes/local/mytheme
[00:41:09] Finished 'copy_build' after 326 ms
You have this line in your task:
.pipe(paths.themeDest);
You probably mean:
.pipe(gulp.dest(paths.themeDest));
For your other question look at merging two gulp.src streams for how to return:
var merge = require('merge-stream');
gulp.task('copy_theme_files', function() {
console.log('[copy_theme_files] Console Log: copy '+paths.themeSrc+' to '+paths.themeDest);
const themesStream = gulp.src(paths.themeSrc)
.pipe(gulp.dest(paths.themeDest));
const imagesStream = gulp.src(paths.root + '/*.{png,ico,svg}')
.pipe(paths.themeDest);
return merge(themesStream , imagesStream );
});

Gcloud background functions with depedencies fail to deploy

Below is a basic example of gcloud background function with a dependency in it. On using uuid package it throws up an error although package.json has uuid
On deploying following erros is received.
gcloud beta functions deploy helloPubSub --trigger-resource my-topic --trigger-event google.pubsub.topic.publish
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function load error: Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'uuid'
index.js
const uuid = require('uuid');
exports.helloPubSub = (event, callback) => {
const pubsubMessage = event.data;
const eventName = pubsubMessage.data ? Buffer.from(pubsubMessage.data, 'base64').toString() : 'World';
console.log(eventName,uuid.v4());
callback();
};
package.json
"dependencies": {
"uuid": "^3.2.1"
},
There was an issue in my .gcloudignore
Below change did make it work!
From
node_modules/
to
node_modules

Jasmine Protractor Reporter

I have installed:
$ npm install protractor-jasmine2-html-reporter --save-dev
for reporter
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
// ...
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
}
}
and defined the path where the reporter is installed
var Jasmine2HtmlReporter =
require('../../build/node_modules/protractor-jasmine2-html-reporter');
Now i get this Error:
configParser - ReferenceError: jasmine is not defined
How should i define jasmine?
For info: i have a test execution task defined in a gulp file and i run the task using webstorm.
I have seen ReferenceError: jasmine is not defined in other reporters(jasmine-repoters) when there is a version mismatch.
Can you upgrade your protractor & reporter versions. Also make sure you have Jasmine2 as the framework in your config file
The below combination has been tested and is working fine
Protractor - 4.0.10
protractor-jasmine2-html-reporter - 0.0.7
Jasmine ~2

Why "gulp-jest" is failing with: "Please run node with the --harmony flag!"?

I get the following error when running gulp test:
Error: Please run node with the --harmony flag!
Here is my gulp task:
var jest = require('gulp-jest');
gulp.task('test', function() {
return gulp.src('src/**/__tests__').pipe(jest({
rootDir: 'src',
scriptPreprocessor: '../node_modules/6to5-jest',
unmockedModulePathPatterns: [ 'react' ]
}));
});
To reproduce: https://github.com/SEEK-Jobs/react-playground
Note that npm test works properly (test is failing as expected), but gulp test fails with the error above. Both npm test and gulp test have the same config object:
{
rootDir: 'src',
scriptPreprocessor: '../node_modules/6to5-jest',
unmockedModulePathPatterns: [ 'react' ]
}
What am I doing wrong?
As far as I can tell the error is thrown from jest-cli.
The reason you don't get it with npm test is that you probably configured npm to run the jest bin script directly, which uses harmonize to programmatically set the --harmony flag.
You can fix by installing harmonize and putting require('harmonize')() in your gulpfile.
It was a bug in gulp-eslint, and it is fixed now in version 0.3.0.