Comparing version 0.1.1 to 0.1.2
26
index.js
@@ -48,14 +48,18 @@ (function() { | ||
run = function(options) { | ||
var ext, file, filePath, files, stat, _i, _len; | ||
var ext, file, filePath, files, stat, _i, _len, _results; | ||
files = options.args || []; | ||
_results = []; | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
stat = fs.statSync(file); | ||
ext = path.extname(file); | ||
filePath = path.resolve(cwd, file); | ||
if (!fs.existsSync(filePath)) { | ||
continue; | ||
} | ||
stat = fs.statSync(filePath); | ||
ext = path.extname(filePath); | ||
if (!(stat.isFile() && ext === ".ics")) { | ||
return; | ||
continue; | ||
} | ||
filePath = path.join(cwd, file); | ||
fs.readFile(filePath, function(error, buffer) { | ||
var basename, output, writePath; | ||
_results.push(fs.readFile(filePath, function(error, buffer) { | ||
var basename, dirname, output, writePath; | ||
if (error != null) { | ||
@@ -65,7 +69,9 @@ throw new Error(error); | ||
output = convert(buffer.toString()); | ||
basename = path.basename(file, ext); | ||
writePath = path.join(cwd, basename) + ".json"; | ||
basename = path.basename(filePath, ext); | ||
dirname = path.dirname(filePath); | ||
writePath = path.join(dirname, basename) + ".json"; | ||
return fs.writeFile(writePath, JSON.stringify(output, null, " ")); | ||
}); | ||
})); | ||
} | ||
return _results; | ||
}; | ||
@@ -72,0 +78,0 @@ |
{ | ||
"name": "ical2json", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A simple node package to convert ical to JSON", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
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
10012
74