rheactor-build-views
Advanced tools
Comparing version 2.0.1 to 3.0.0
29
index.js
@@ -36,3 +36,6 @@ #!/usr/bin/env node | ||
let svgIncludes = {} | ||
let directives = {} | ||
source = path.resolve(source) | ||
const sourceDir = fs.statSync(source).isFile() ? path.dirname(source) : source | ||
target = path.resolve(target) | ||
const targetDir = path.dirname(target) | ||
@@ -57,3 +60,3 @@ /** | ||
let scanForIncludes = [ | ||
globAsync(source + '/includes/*.html') | ||
globAsync(sourceDir + '/includes/*.html') | ||
] | ||
@@ -66,6 +69,5 @@ if (options.include) { | ||
Promise.all(scanForIncludes), | ||
globAsync(source + '/js/directives/*.html'), | ||
globAsync(options.svg ? options.svg : source + '/img/*.svg') | ||
globAsync(options.svg ? options.svg : sourceDir + '/img/*.svg') | ||
) | ||
.spread((includeTemplates, directiveTemplates, svgFiles) => Promise | ||
.spread((includeTemplates, svgFiles) => Promise | ||
.map(svgFiles, (file) => { | ||
@@ -91,3 +93,3 @@ return fs.readFileAsync(file, 'utf8').then(data => { | ||
return fs.readFileAsync(file, 'utf8').then((data) => { | ||
let trg = file.replace(source + '/includes/', '') | ||
let trg = file.replace(sourceDir + '/includes/', '') | ||
if (options.include) { | ||
@@ -109,11 +111,2 @@ trg = trg.replace(options.include, '') | ||
}) | ||
}), | ||
Promise.map(directiveTemplates, (file) => { | ||
return fs.readFileAsync(file, 'utf8').then((data) => { | ||
let trg = file.replace(source + '/js/directives/', '') | ||
trg = trg.replace(/\.html$/, '') | ||
trg = trg.replace(/\//, '.') | ||
data = _template(data)({data: templatedata}) | ||
directives[trg] = data | ||
}) | ||
}) | ||
@@ -139,6 +132,6 @@ )) | ||
}) | ||
return globAsync(source + '/*.html') | ||
return globAsync(sourceDir === source ? sourceDir + '/*.html' : source) | ||
.map((src) => { | ||
return fs.readFileAsync(src, 'utf8').then((data) => { | ||
data = _template(data)({data: templatedata, includes: includes, directives: directives, svg: svgIncludes}) | ||
data = _template(data)({data: templatedata, includes: includes, svg: svgIncludes}) | ||
if (options.minify) { | ||
@@ -155,3 +148,3 @@ data = minify(data, { | ||
} | ||
let trg = target + '/' + src.replace(source + '/', '') | ||
const trg = path.join(targetDir, path.basename(src)) | ||
console.log(src + ' -> ' + trg) | ||
@@ -158,0 +151,0 @@ return fs.writeFileAsync(trg, data) |
@@ -42,3 +42,3 @@ { | ||
}, | ||
"version": "2.0.1" | ||
"version": "3.0.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
9450
171