asset-assistant
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "asset-assistant", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "util", |
@@ -88,2 +88,3 @@ const fs = require("fs"); | ||
build() { | ||
this.debugLog("AbstractAssets.build()"); | ||
let filename = this.srcRoot + "package.json"; | ||
@@ -99,6 +100,6 @@ | ||
this.debugLog(`skipping package ${this.package.name}, 'assets' parameter not found`); | ||
this.debugLog("AbstractAssets.build() : false"); | ||
return false; | ||
} | ||
this.log(`Traversing package ${this.package.name}`); | ||
this.options = {...AbstractAssets.defaults, ...this.package.assets}; | ||
@@ -115,2 +116,3 @@ this.options.up = this.options.up + (this.depth * 2); | ||
this.debugLog("AbstractAssets.build() : true"); | ||
return true; | ||
@@ -117,0 +119,0 @@ } |
@@ -15,5 +15,7 @@ #!/usr/bin/env node | ||
.boolean("r") | ||
.boolean("l") | ||
.default("s", false) | ||
.default("v", false) | ||
.default("d", false) | ||
.default("l", true) | ||
.default("dry", false) | ||
@@ -25,5 +27,6 @@ .default("r", true) | ||
.describe("r", "set to false to not recurse over modules") | ||
.describe("l", "set to false to not run local copy") | ||
.describe("s", "selent, do not print out to console") | ||
.describe("v", "verbose, print out more information") | ||
.describe("d", "debug, print out even more information") | ||
.describe("d", "debug, print out even more information") | ||
.argv; | ||
@@ -33,3 +36,14 @@ | ||
if (!argv.s) console.log("Asset Assistant : v0.0.3"); | ||
if (!argv.s) console.log("Asset Assistant : v0.0.4"); | ||
if (argv.d){ | ||
console.log(`-s ${argv.s}`); | ||
console.log(`-v ${argv.v}`); | ||
console.log(`-d ${argv.d}`); | ||
console.log(`-l ${argv.l}`); | ||
console.log(`-r ${argv.r}`); | ||
console.log(`-dry ${argv.dry}`); | ||
console.log(`-fileset ${argv.fileset}`); | ||
console.log(`-clean ${argv.clean}`); | ||
console.log(``); | ||
} | ||
@@ -45,5 +59,6 @@ if (argv.clean) task = new CleanAssets(); | ||
if (task.build()) { | ||
if (argv.local) task.assets(argv.fileset); | ||
if (argv.dependencies) task.dependencies(argv.fileset); | ||
let traversedList = []; | ||
if (argv.l) task.assets(argv.fileset, traversedList); | ||
if (argv.r) task.dependencies(argv.fileset, traversedList); | ||
if (argv.clean) task.directories(); | ||
} |
@@ -14,6 +14,17 @@ const AbstractAssets = require("./AbstractAssets"); | ||
* to peform the copy task. | ||
* @param {type} field, an array of strings representing glob paths. | ||
* @param {type} field, parameter in this.options that contains an array of | ||
* strings representing glob paths. | ||
* @returns {undefined} | ||
*/ | ||
assets(field) { | ||
assets(field, traversedList) { | ||
this.debugLog(`LoadAssets.assets(${field})`); | ||
if (traversedList.includes(this.package.name)){ | ||
this.log(`Package ${this.package.name} previously traversed`); | ||
return; | ||
} | ||
traversedList.push(this.package.name); | ||
this.log(`Traversing package ${this.package.name}`); | ||
for (let i in this.options[field]) { | ||
@@ -25,15 +36,17 @@ let src = this.options[field][i]; | ||
let copyObj = srcArray[idx]; | ||
if (!this.isDry()){ | ||
this.log(`Creating directory ${copyObj.dest}`) | ||
let src = copyObj.src + copyObj.file; | ||
let dest = copyObj.dest + copyObj.file; | ||
if (!this.isDry() && !fs.existsSync(copyObj.dest)){ | ||
this.log(` Creating directory ${copyObj.dest}`) | ||
mkdirp.sync(copyObj.dest); | ||
} | ||
let src = copyObj.src + copyObj.file; | ||
let dest = copyObj.dest + copyObj.file; | ||
if (fs.statSync(src).isDirectory()) continue; | ||
this.log(` ${src} -> ${dest}`); | ||
this.log(` -> ${dest}`); | ||
if (!this.isDry()) fs.copyFileSync(src, dest); | ||
} | ||
} | ||
this.log(`+-----------------------------+`); | ||
} | ||
@@ -48,3 +61,4 @@ | ||
*/ | ||
dependencies(field) { | ||
dependencies(field, traversedList) { | ||
this.debugLog(`LoadAssets.dependencies(${field})`); | ||
if (this.package.dependencies === undefined) return; | ||
@@ -60,4 +74,4 @@ | ||
loadAssets.setDest(this.getDest()); | ||
loadAssets.assets(field); | ||
loadAssets.dependencies(field); | ||
loadAssets.assets(field, traversedList); | ||
loadAssets.dependencies(field, traversedList); | ||
} | ||
@@ -64,0 +78,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23514
443