@nowa/module-file
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -7,3 +7,3 @@ import { Module } from '@nowa/core'; | ||
run(): Promise<void>; | ||
private _getFiles(filePath); | ||
private _getFiles; | ||
} | ||
@@ -10,0 +10,0 @@ export declare namespace ModuleFile { |
18
index.js
@@ -56,4 +56,4 @@ "use strict"; | ||
const target = path_1.resolve(context, action.to); | ||
const isDir = action.to.endsWith('/'); | ||
if (!isDir && files.length > 1) { | ||
const targetIsDir = action.to.endsWith('/'); | ||
if (!targetIsDir && files.length > 1) { | ||
logger.error(`in`, action); | ||
@@ -63,3 +63,3 @@ logger.error(`${action.type} multiple files to a single file is not valid`); | ||
} | ||
if (isDir) { | ||
if (targetIsDir) { | ||
yield fs_extra_1.ensureDir(target); | ||
@@ -72,5 +72,9 @@ } | ||
yield Promise.all(files.map(file => { | ||
const dest = isDir ? path_1.resolve(target, path_1.basename(file)) : target; | ||
logger.debug(`copy ${file} to ${dest}`); | ||
return fs_extra_1.copy(file, dest, { overwrite: true }); | ||
return fs_extra_1.stat(file) | ||
.then(stat => stat.isDirectory()) | ||
.then(sourceIsDir => { | ||
const dest = targetIsDir ? (sourceIsDir ? target : path_1.resolve(target, path_1.basename(file))) : target; | ||
logger.debug(`copy ${file} to ${dest}`); | ||
return fs_extra_1.copy(file, dest, { overwrite: true }); | ||
}); | ||
})); | ||
@@ -81,3 +85,3 @@ logger.info(`copied ${files.length} file(s) / folder(s)`); | ||
yield Promise.all(files.map(file => { | ||
const dest = isDir ? path_1.resolve(target, path_1.basename(file)) : target; | ||
const dest = targetIsDir ? path_1.resolve(target, path_1.basename(file)) : target; | ||
logger.debug(`copy ${file} to ${dest}`); | ||
@@ -84,0 +88,0 @@ return fs_extra_1.move(file, dest, { overwrite: true }); |
{ | ||
"name": "@nowa/module-file", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "the nowa file module", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
10468
131