-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy hooks assets not only in api/hooks folder but in production and …
…tmp folder too
- Loading branch information
1 parent
f474b75
commit 9131b1a
Showing
1 changed file
with
53 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,55 @@ | ||
var fs = require('fs'); | ||
var fse = require('fs-extra') | ||
|
||
module.exports = function (grunt) { | ||
|
||
grunt.registerTask('copyHooksAssets', 'Copy all hooks assets', function() { | ||
|
||
var done = this.async(); | ||
var path = './api/hooks/'; | ||
var assetsDestination = './assets/hooks/'; | ||
|
||
// we first get sure that the hooks directory exist | ||
fse.ensureDirSync(path); | ||
|
||
// first, we clean the assets hooks directory | ||
// if the directory does not exist, it is created | ||
fse.emptyDirSync(assetsDestination); | ||
|
||
// we read all the modules | ||
var modules = fs.readdirSync(path); | ||
|
||
// foreach module | ||
modules.forEach(function(module){ | ||
|
||
// we test if it's a directory | ||
if(fs.lstatSync(path + module).isDirectory()){ | ||
|
||
// we test if there is an assets folder to copy | ||
try{ | ||
var assetsDir = path + module + '/assets'; | ||
if(fs.lstatSync(assetsDir).isDirectory()){ | ||
|
||
// copying assets of module | ||
console.log('Copying assets of module ' + module); | ||
fse.copySync(assetsDir, assetsDestination + module); | ||
} | ||
} catch(e){ | ||
console.log('No assets to copy for module ' + module); | ||
} | ||
|
||
} | ||
}); | ||
done(); | ||
var fse = require('fs-extra'); | ||
|
||
module.exports = function(grunt) { | ||
|
||
grunt.registerTask('copyHooksAssets', 'Copy all hooks assets', function() { | ||
|
||
var done = this.async(); | ||
var path = './api/hooks/'; | ||
var assetsDestination = './assets/hooks/'; | ||
|
||
// we first get sure that the hooks directory exist | ||
fse.ensureDirSync(path); | ||
|
||
// first, we clean the assets hooks directory | ||
// if the directory does not exist, it is created | ||
fse.emptyDirSync(assetsDestination); | ||
|
||
// we read all the modules | ||
var modules = fs.readdirSync(path); | ||
|
||
// foreach module | ||
modules.forEach(function(module) { | ||
|
||
// we test if it's a directory | ||
if (fs.lstatSync(path + module).isDirectory()) { | ||
|
||
// we test if there is an assets folder to copy | ||
try { | ||
var assetsDir = path + module + '/assets'; | ||
if (fs.lstatSync(assetsDir).isDirectory()) { | ||
|
||
// copying assets of module | ||
console.log('Copying assets of module ' + module); | ||
fse.copySync(assetsDir, assetsDestination + module); | ||
} | ||
} catch (e) { | ||
console.log('No assets to copy for module ' + module); | ||
} | ||
|
||
} | ||
}); | ||
}; | ||
|
||
var assetsDestinationProd = './www/hooks/'; | ||
var assetsDestinationProdTmp = './.tmp/public/hooks/'; | ||
|
||
console.log('Copying all assets to ' + assetsDestinationProd); | ||
fse.copySync(assetsDestination, assetsDestinationProd); | ||
|
||
console.log('Copying all assets to ' + assetsDestinationProdTmp); | ||
fse.copySync(assetsDestination, assetsDestinationProdTmp); | ||
|
||
done(); | ||
}); | ||
}; |