firasKoubaa firasKoubaa -4 years ago 101
Javascript Question

Running shell under gulp : evitate the antislash (\) character exlusion effect

I'm running shell tasks under Gulp

By the manner i'm used to write shell syntax with javascript.

Among my tasks i wanna execute a "zip" tas with excluding some files ; my origin shell command is this :

'zip -9 -r project.zip ./* -x *.svn* -x custom/\*


As you can see i'm excluding the whole "custom" repo.

My gulp task is that one :

gulp.task('package-IC', shell.task([
'zip -9 -r project.zip ./* -x *.svn* -x custom/\*
]));


But the problem that with javascript the succession of the characheters
\*

eliminates the
*
from the command .

How can i keep the anti-slash \ without loosing the character just after it ?

Suggestions ??

Answer Source

Backslashes in JavaScript strings have special meaning, since they can be used for escape sequences. You need to escape the backslash character itself:

'zip -9 -r project.zip ./* -x *.svn* -x custom/\\*'

Also your gulp example code is missing the closing single quote.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download