Skip to content

Commit

Permalink
[fixes #132] - Fixed issue with asFiles and path issues
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Jan 18, 2018
1 parent 44eb9d5 commit 6c5274c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,14 @@ exports.asFiles = function(json, outDir) {
mkdirp.sync(outDir);
Object.keys(json).forEach(function(moduleName) {
var licenseFile = json[moduleName].licenseFile,
fileContents, outFileName, outPath;
fileContents, outFileName, outPath, baseDir;

if (licenseFile && fs.existsSync(licenseFile)) {
fileContents = fs.readFileSync(licenseFile);
outFileName = chalk.stripColor(moduleName).replace(/(\s+|@)/g, "") + "-LICENSE.txt";
outFileName = chalk.stripColor(moduleName).replace(/(\s+|@|\/)/g, "") + "-LICENSE.txt";
outPath = path.join(outDir, outFileName);
baseDir = path.dirname(outPath);
mkdirp.sync(baseDir);
fs.writeFileSync(outPath, fileContents, "utf8");
} else {
console.warn("no license file found for: " + moduleName);
Expand Down

0 comments on commit 6c5274c

Please sign in to comment.