mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
Multi-dest the LICENCE file
This commit is contained in:
58
gruntfile.js
58
gruntfile.js
@ -58,6 +58,22 @@ module.exports = function(grunt) {
|
||||
return content;
|
||||
};
|
||||
|
||||
var getSubDirs = function(dir) {
|
||||
var allObjects = fs.readdirSync(dir);
|
||||
var allDirs = [];
|
||||
for (var i=0; i<allObjects.length; i++)
|
||||
{
|
||||
var currentObjName = allObjects[i];
|
||||
var currentObjPath = pathModule.join(dir, currentObjName);
|
||||
var stats = fs.statSync(currentObjPath);
|
||||
if (stats.isDirectory())
|
||||
{
|
||||
allDirs.push({name: currentObjName, path: currentObjPath});
|
||||
}
|
||||
}
|
||||
return allDirs;
|
||||
}
|
||||
|
||||
var localCfg = {
|
||||
srcDir: ".",
|
||||
srcAppsDir: "./apps",
|
||||
@ -129,6 +145,12 @@ module.exports = function(grunt) {
|
||||
dest: "<%= localCfg.outModulesDir %>/",
|
||||
cwd: localCfg.srcDir
|
||||
},
|
||||
appLicense: {
|
||||
expand: true,
|
||||
src: ["./LICENSE"],
|
||||
cwd: localCfg.srcAppsDir,
|
||||
dest: "__dummy__"
|
||||
},
|
||||
definitionFiles: {
|
||||
src: [
|
||||
localCfg.srcDir + "/**/*.d.ts",
|
||||
@ -188,7 +210,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
readyAppFiles: {
|
||||
expand: true,
|
||||
src: ["./**/*.*", "../LICENSE"],
|
||||
src: ["./**/*.*"],
|
||||
dest: localCfg.outAppsDir + "/",
|
||||
cwd: localCfg.outModulesDir + "/apps/",
|
||||
options: {
|
||||
@ -197,7 +219,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
readyTsAppFiles: {
|
||||
expand: true,
|
||||
src: ["./**/*.*", "!./**/*.map", "../LICENSE"],
|
||||
src: ["./**/*.*", "!./**/*.map"],
|
||||
dest: localCfg.outTsAppsDir + "/",
|
||||
cwd: localCfg.srcAppsDir
|
||||
},
|
||||
@ -246,6 +268,20 @@ module.exports = function(grunt) {
|
||||
cmd: "npm pack",
|
||||
cwd: "__dummy__"
|
||||
}
|
||||
},
|
||||
multidest: {
|
||||
copyLicenseFiles: {
|
||||
tasks: ["copy:appLicense"],
|
||||
dest: function() {
|
||||
var apps = getSubDirs(localCfg.srcAppsDir);
|
||||
var targetDirs = [];
|
||||
apps.forEach(function(item){
|
||||
targetDirs.push(pathModule.join(localCfg.outAppsDir, item.name));
|
||||
targetDirs.push(pathModule.join(localCfg.outTsAppsDir, item.name));
|
||||
});
|
||||
return targetDirs;
|
||||
}()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -254,22 +290,7 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks("grunt-contrib-copy");
|
||||
grunt.loadNpmTasks("grunt-exec");
|
||||
grunt.loadNpmTasks("grunt-tslint");
|
||||
|
||||
var getSubDirs = function(dir) {
|
||||
var allObjects = fs.readdirSync(dir);
|
||||
var allDirs = [];
|
||||
for (var i=0; i<allObjects.length; i++)
|
||||
{
|
||||
var currentObjName = allObjects[i];
|
||||
var currentObjPath = pathModule.join(dir, currentObjName);
|
||||
var stats = fs.statSync(currentObjPath);
|
||||
if (stats.isDirectory())
|
||||
{
|
||||
allDirs.push({name: currentObjName, path: currentObjPath});
|
||||
}
|
||||
}
|
||||
return allDirs;
|
||||
}
|
||||
grunt.loadNpmTasks("grunt-multi-dest");
|
||||
|
||||
var cloneTasks = function(originalTasks, taskNameSuffix)
|
||||
{
|
||||
@ -333,6 +354,7 @@ module.exports = function(grunt) {
|
||||
|
||||
grunt.registerTask("collect-apps-raw-files", [
|
||||
"copy:rawAppsFiles",
|
||||
"multidest:copyLicenseFiles"
|
||||
]);
|
||||
|
||||
// Does nothing to avoid copying the same files twice. Instead,
|
||||
|
@ -12,6 +12,7 @@
|
||||
"grunt-contrib-clean": "0.5.0",
|
||||
"grunt-contrib-copy": "0.5.0",
|
||||
"grunt-exec": "0.4.5",
|
||||
"grunt-multi-dest": "1.0.0",
|
||||
"grunt-ts": "1.12.1",
|
||||
"grunt-tslint": "0.4.2",
|
||||
"typescript": "1.4.1"
|
||||
|
Reference in New Issue
Block a user