Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to b.download() #370

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 7 additions & 5 deletions basil.js
Original file line number Diff line number Diff line change
Expand Up @@ -5117,7 +5117,7 @@ pub.shellExecute = function(cmd) {
* @param {String|File} [file] A relative file path in the project folder or a File instance
*/
pub.download = function(url, file) {
var projPath = pub.projectFolder().fsName.replace(" ", "\\ ");
var projPath = pub.projectFolder().fsName.replace(/ /g, "\\ ");
// var scriptPath = "~/Documents/basiljs/bundle/lib/download.sh";
// This is more portable then a fixed location
// the Script looks for the lib folder next to itself
Expand Down Expand Up @@ -5169,12 +5169,14 @@ pub.download = function(url, file) {
if (isURL(url)) {
var cmd = null;

url = "\"" + url + "\"";

if (file) {
if (file instanceof File) {
var downloadFolder = file.parent.fsName;
var fileName = file.displayName;
downloadFolder = downloadFolder.replace(" ", "\\ ");
fileName = fileName.replace(" ", "\\ ");
downloadFolder = downloadFolder.replace(/ /g, "\\ ");
fileName = fileName.replace(/ /g, "\\ ");
cmd = ["sh", scriptPath, downloadFolder, url, fileName].join(" ");

} else {
Expand All @@ -5185,8 +5187,8 @@ pub.download = function(url, file) {
if(startsWith(downloadFolder, "./")) downloadFolder.substr(2);
if(startsWith(downloadFolder, "/")) downloadFolder.substr(1);

downloadFolder = downloadFolder.replace(" ", "\\ ");
fileName = fileName.replace(" ", "\\ ");
downloadFolder = downloadFolder.replace(/ /g, "\\ ");
fileName = fileName.replace(/ /g, "\\ ");
downloadFolder = projPath + "/data/" + downloadFolder;
cmd = ["sh", scriptPath, downloadFolder, url, fileName].join(" ");

Expand Down
12 changes: 7 additions & 5 deletions src/includes/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub.shellExecute = function(cmd) {
* @param {String|File} [file] A relative file path in the project folder or a File instance
*/
pub.download = function(url, file) {
var projPath = pub.projectFolder().fsName.replace(" ", "\\ ");
var projPath = pub.projectFolder().fsName.replace(/ /g, "\\ ");
// var scriptPath = "~/Documents/basiljs/bundle/lib/download.sh";
// This is more portable then a fixed location
// the Script looks for the lib folder next to itself
Expand Down Expand Up @@ -98,12 +98,14 @@ pub.download = function(url, file) {
if (isURL(url)) {
var cmd = null;

url = "\"" + url + "\"";

if (file) {
if (file instanceof File) {
var downloadFolder = file.parent.fsName;
var fileName = file.displayName;
downloadFolder = downloadFolder.replace(" ", "\\ ");
fileName = fileName.replace(" ", "\\ ");
downloadFolder = downloadFolder.replace(/ /g, "\\ ");
fileName = fileName.replace(/ /g, "\\ ");
cmd = ["sh", scriptPath, downloadFolder, url, fileName].join(" ");

} else {
Expand All @@ -114,8 +116,8 @@ pub.download = function(url, file) {
if(startsWith(downloadFolder, "./")) downloadFolder.substr(2);
if(startsWith(downloadFolder, "/")) downloadFolder.substr(1);

downloadFolder = downloadFolder.replace(" ", "\\ ");
fileName = fileName.replace(" ", "\\ ");
downloadFolder = downloadFolder.replace(/ /g, "\\ ");
fileName = fileName.replace(/ /g, "\\ ");
downloadFolder = projPath + "/data/" + downloadFolder;
cmd = ["sh", scriptPath, downloadFolder, url, fileName].join(" ");

Expand Down