Skip to content

Commit a5a95de

Browse files
committed
Multi-dest the LICENCE file
1 parent 6ad062b commit a5a95de

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

gruntfile.js

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ module.exports = function(grunt) {
5858
return content;
5959
};
6060

61+
var getSubDirs = function(dir) {
62+
var allObjects = fs.readdirSync(dir);
63+
var allDirs = [];
64+
for (var i=0; i<allObjects.length; i++)
65+
{
66+
var currentObjName = allObjects[i];
67+
var currentObjPath = pathModule.join(dir, currentObjName);
68+
var stats = fs.statSync(currentObjPath);
69+
if (stats.isDirectory())
70+
{
71+
allDirs.push({name: currentObjName, path: currentObjPath});
72+
}
73+
}
74+
return allDirs;
75+
}
76+
6177
var localCfg = {
6278
srcDir: ".",
6379
srcAppsDir: "./apps",
@@ -129,6 +145,12 @@ module.exports = function(grunt) {
129145
dest: "<%= localCfg.outModulesDir %>/",
130146
cwd: localCfg.srcDir
131147
},
148+
appLicense: {
149+
expand: true,
150+
src: ["./LICENSE"],
151+
cwd: localCfg.srcAppsDir,
152+
dest: "__dummy__"
153+
},
132154
definitionFiles: {
133155
src: [
134156
localCfg.srcDir + "/**/*.d.ts",
@@ -188,7 +210,7 @@ module.exports = function(grunt) {
188210
},
189211
readyAppFiles: {
190212
expand: true,
191-
src: ["./**/*.*", "../LICENSE"],
213+
src: ["./**/*.*"],
192214
dest: localCfg.outAppsDir + "/",
193215
cwd: localCfg.outModulesDir + "/apps/",
194216
options: {
@@ -197,7 +219,7 @@ module.exports = function(grunt) {
197219
},
198220
readyTsAppFiles: {
199221
expand: true,
200-
src: ["./**/*.*", "!./**/*.map", "../LICENSE"],
222+
src: ["./**/*.*", "!./**/*.map"],
201223
dest: localCfg.outTsAppsDir + "/",
202224
cwd: localCfg.srcAppsDir
203225
},
@@ -246,6 +268,20 @@ module.exports = function(grunt) {
246268
cmd: "npm pack",
247269
cwd: "__dummy__"
248270
}
271+
},
272+
multidest: {
273+
copyLicenseFiles: {
274+
tasks: ["copy:appLicense"],
275+
dest: function() {
276+
var apps = getSubDirs(localCfg.srcAppsDir);
277+
var targetDirs = [];
278+
apps.forEach(function(item){
279+
targetDirs.push(pathModule.join(localCfg.outAppsDir, item.name));
280+
targetDirs.push(pathModule.join(localCfg.outTsAppsDir, item.name));
281+
});
282+
return targetDirs;
283+
}()
284+
}
249285
}
250286
});
251287

@@ -254,22 +290,7 @@ module.exports = function(grunt) {
254290
grunt.loadNpmTasks("grunt-contrib-copy");
255291
grunt.loadNpmTasks("grunt-exec");
256292
grunt.loadNpmTasks("grunt-tslint");
257-
258-
var getSubDirs = function(dir) {
259-
var allObjects = fs.readdirSync(dir);
260-
var allDirs = [];
261-
for (var i=0; i<allObjects.length; i++)
262-
{
263-
var currentObjName = allObjects[i];
264-
var currentObjPath = pathModule.join(dir, currentObjName);
265-
var stats = fs.statSync(currentObjPath);
266-
if (stats.isDirectory())
267-
{
268-
allDirs.push({name: currentObjName, path: currentObjPath});
269-
}
270-
}
271-
return allDirs;
272-
}
293+
grunt.loadNpmTasks("grunt-multi-dest");
273294

274295
var cloneTasks = function(originalTasks, taskNameSuffix)
275296
{
@@ -333,6 +354,7 @@ module.exports = function(grunt) {
333354

334355
grunt.registerTask("collect-apps-raw-files", [
335356
"copy:rawAppsFiles",
357+
"multidest:copyLicenseFiles"
336358
]);
337359

338360
// Does nothing to avoid copying the same files twice. Instead,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"grunt-contrib-clean": "0.5.0",
1313
"grunt-contrib-copy": "0.5.0",
1414
"grunt-exec": "0.4.5",
15+
"grunt-multi-dest": "1.0.0",
1516
"grunt-ts": "1.12.1",
1617
"grunt-tslint": "0.4.2",
1718
"typescript": "1.4.1"

0 commit comments

Comments
 (0)