Closed AliOsseili closed 6 years ago
I think filepath
is the full filepath so you're doubly nesting the filepath. Try out:
'zip': {
'skip-files': {
router: function (filepath) {
var extname = path.extname(filepath)
if (extname === '.zip') {
return null;
} else {
return filepath;
}
},
src: ['build/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '/**'],
dest: 'BuildZip/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '-' + TimeNow + '.zip'
}
}
now its nesting it once, is there a way to avoid doing that? I just want the zip to contain what I want zipped instead of having:
electronfeedleft.... .zip -build -electronfeedleft
I'd like
electronfeedleft.... .zip -all that I wwant zipped
Ahhh, I understand. Yea, using path.basename
we can extract the root filename:
https://nodejs.org/api/path.html#path_path_basename_path_ext
'zip': {
'skip-files': {
router: function (filepath) {
var extname = path.extname(filepath)
if (extname === '.zip') {
return null;
} else {
return path.basename(filepath);
}
},
src: ['build/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '/**'],
dest: 'BuildZip/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '-' + TimeNow + '.zip'
}
}
When I tried that it gave me even more files lol: What it should look like
what it actually does
I think your glob pattern is off. Try **/*
instead of **
:
'zip': {
'skip-files': {
router: function (filepath) {
var extname = path.extname(filepath)
if (extname === '.zip') {
return null;
} else {
return path.basename(filepath);
}
},
src: ['build/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '/**/*'],
dest: 'BuildZip/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '-' + TimeNow + '.zip'
}
}
Fixed the issue here: https://github.com/twolfson/grunt-zip/issues/50 by using the routers skipping files option, but now when I open my zip it has too many unnecessary folders, here is what it should look like: enhancedfeedleft-win32-x64(time).zip
here is what it actually looks like
enhancedFeedLeft-win32-x64(time).zip -build -enhancedfeedleft...
any ideas on how to fix that, here is what my grunt zip task looks like:
'zip': { 'skip-files': { router: function (filepath) { var extname = path.extname(filepath) if (extname === '.zip') { return null; } else { return 'build/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '/'+filepath; } }, src: ['build/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '/**'], dest: 'BuildZip/enhancedFeedLeft' + '-' + os_platform + '-' + arch_model + '-' + TimeNow + '.zip' } }