Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ function slang(opt) {
var PORT = opt.port || 4502;
var USER = opt.username || 'admin';
var PASS = opt.password || 'admin';
var BASE = opt.base;
var DEST = opt.dest;
var URL;

// return stream to gulp
Expand All @@ -33,13 +35,22 @@ function slang(opt) {
cb(new gutil.PluginError('gulp-slang', 'Streaming not supported'));
return;
}
// if jcr_root is in file system path, remove before setting destination
var destPath = file.path;
if (path.dirname(destPath).indexOf('jcr_root') !== -1) {
// BASE will be removed from the destination path if is set and in file system path
if (BASE && path.dirname(destPath).indexOf(BASE) !== -1) {
destPath = destPath.substring(path.dirname(destPath)
.indexOf(BASE) + BASE.length);
// if jcr_root is in file system path, remove before setting destination
} else if (path.dirname(destPath).indexOf('jcr_root') !== -1) {
destPath = destPath.substring(path.dirname(destPath)
.indexOf('jcr_root') + 9);
}

// DEST will be prepended to the destination path if is set
if (DEST) {
destPath = DEST + destPath;
}

// create full URL for curl path
URL = 'http://' + USER + ':' + encodeURIComponent(PASS) + '@' +
HOST + ':' + PORT + '/' + path.dirname(destPath) + ".json";
Expand Down