Comparing version
@@ -14,12 +14,18 @@ /** | ||
exec = require('child_process').exec, | ||
cloudpt = require('nodecloudpt')(config); | ||
meocloud = require('meocloud')(config); | ||
var CLOUDIFY_FOLDER = '/cloudify'; | ||
var run = function() { | ||
var options = { path: '/cloudify', list: false }; | ||
cloudpt.metadata(options, function(data) { | ||
// we dont support directories, for now | ||
if (data && data.is_dir === false) { | ||
cloudpt.createFolder({ path: '/cloudify' }, upload); | ||
var options = { list: false }; | ||
meocloud.metadata(CLOUDIFY_FOLDER, options, function(err, data) { | ||
if (data && data.is_dir === true && !data.is_deleted) { | ||
upload(true); | ||
} else { | ||
upload(); | ||
console.log('Cloudify folder does not exist. Creating...'); | ||
meocloud.createFolder({ path: CLOUDIFY_FOLDER }, function(err, data) { | ||
if (err) { throw err; } | ||
var success = data && data.is_dir === true; | ||
return upload(success); | ||
}); | ||
} | ||
@@ -30,13 +36,21 @@ return; | ||
var upload = function() { | ||
var options = { | ||
path: '/cloudify/' + path.basename(filename), | ||
file: filename | ||
}; | ||
var upload = function(data) { | ||
if (!data) { | ||
console.log('Error: /cloudify folder could not be created remotely'); | ||
process.exit(-1); | ||
} | ||
var destinationPath = CLOUDIFY_FOLDER + '/' + path.basename(filename); | ||
var fileStats = fs.statSync(filename); | ||
var fileSize = getPrettyFileSize(fileStats.size); | ||
console.log('Uploading (' + fileSize +') ...'); | ||
cloudpt.upload(options, function(data) { | ||
meocloud.upload(filename, destinationPath, {}, function(err, data, status) { | ||
if (err) { throw err; } | ||
if (status !== 200) { | ||
console.log('Warning: File with same name already exists. Aborting.'); | ||
process.exit(1); | ||
} | ||
if (data) { getPublicLink(); } | ||
@@ -48,10 +62,7 @@ return; | ||
var getPublicLink = function() { | ||
var options = { path: '/cloudify/' + path.basename(filename) }; | ||
cloudpt.shares(options, function(data) { | ||
data = data || null; | ||
try { | ||
data = JSON.parse(data); | ||
} | ||
catch(e) { | ||
console.log('Error: service returned unhandled exception'); | ||
var cpath = CLOUDIFY_FOLDER + '/' + path.basename(filename); | ||
meocloud.shares(cpath, function(err, data, status) { | ||
if (err) { throw err; } | ||
if (status !== 200) { | ||
console.log('Error: service returned status ' + status); | ||
process.exit(0); | ||
@@ -66,4 +77,3 @@ } | ||
saveToPasteboard(outURL); | ||
} | ||
else { | ||
} else { | ||
console.log('Error: unable to get public URL'); | ||
@@ -70,0 +80,0 @@ } |
@@ -17,3 +17,3 @@ { | ||
], | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"repository": { | ||
@@ -24,4 +24,4 @@ "type": "git", | ||
"dependencies": { | ||
"nodecloudpt": ">= 0.5.3", | ||
"oauth": ">= 0.9.10" | ||
"oauth": ">= 0.9.10", | ||
"meocloud": "~0.0.2" | ||
}, | ||
@@ -40,2 +40,5 @@ "engines": { | ||
], | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"licenses": [ | ||
@@ -50,4 +53,6 @@ { | ||
"grunt": "~0.4.1", | ||
"grunt-shell": "~0.4.0" | ||
"grunt-shell": "~0.4.0", | ||
"chai": "~1.8.1", | ||
"mocha": "~1.14.0" | ||
} | ||
} |
@@ -1,21 +0,41 @@ | ||
var assert = require('assert'); | ||
var expect = require('chai').expect, | ||
exec = require('child_process').exec; | ||
describe('Cloudify bin', function() { | ||
describe('test --help', function() { | ||
process.argv = [ | ||
'node', | ||
'cloudify.js', | ||
'--help' | ||
]; | ||
var cloudify = require('./../bin/cloudify'); | ||
it('should output help info when passed -h', function(done) { | ||
exec('./bin/cloudify -h --test', function(error, stdout, stderr) { | ||
expect(error).to.be.null; | ||
expect(stdout).to.match(/^Usage\: cloudify \[options\] \<file\_to\_share\>/); | ||
expect(stderr).to.be.empty; | ||
done(); | ||
}); | ||
}); | ||
describe('test --version', function() { | ||
process.argv = [ | ||
'node', | ||
'cloudify.js', | ||
'--version' | ||
]; | ||
var cloudify = require('./../bin/cloudify'); | ||
it('should output help info when passed --help', function(done) { | ||
exec('./bin/cloudify --help --test', function(error, stdout, stderr) { | ||
expect(error).to.be.null; | ||
expect(stdout).to.match(/^Usage\: cloudify \[options\] \<file\_to\_share\>/); | ||
expect(stderr).to.be.empty; | ||
done(); | ||
}); | ||
}); | ||
it('should output version number when passed -v', function(done) { | ||
exec('./bin/cloudify -v --test', function(error, stdout, stderr) { | ||
expect(error).to.be.null; | ||
expect(stdout).to.match(/^cloudify version/); | ||
expect(stderr).to.be.empty; | ||
done(); | ||
}); | ||
}); | ||
it('should output version number when passed --version', function(done) { | ||
exec('./bin/cloudify --version --test', function(error, stdout, stderr) { | ||
expect(error).to.be.null; | ||
expect(stdout).to.match(/^cloudify version/); | ||
expect(stderr).to.be.empty; | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
15114
17.88%13
18.18%255
15.91%5
66.67%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed