Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
Take a swing at fixing those damn paths
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoTheThird committed May 25, 2018
1 parent 75bfc76 commit 919af9f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions src/client.js
Expand Up @@ -94,10 +94,10 @@ class Client {
}

createInstallCommandsFile(cmds, device) {
if (!fs.existsSync(this.path + "/commandfile/")) {
mkdirp.sync(this.path + "/commandfile/");
if (!fs.existsSync(path.join(this.path, "commandfile"))) {
mkdirp.sync(path.join(this.path, "commandfile"));
}
var file = this.path + "/commandfile/" + ubuntuCommandFile + device + common.getRandomInt(1000, 9999);
var file = path.join(this.path, "commandfile", ubuntuCommandFile + device + common.getRandomInt(1000, 9999));
fs.writeFileSync(file, cmds);
return file;
}
Expand Down Expand Up @@ -196,7 +196,7 @@ class Client {
gpg.forEach((g) => {
gpgUrls.push({
url: this.host + "gpg/" + g,
path: this.path + "/gpg"
path: path.join(this.path, "gpg")
});
});
return gpgUrls;
Expand All @@ -207,12 +207,12 @@ class Client {
index.files.forEach((file) => {
ret.push({
url: this.host + file.path,
path: this.path + "/pool",
path: path.join(this.path, "pool"),
checksum: file.checksum
});
ret.push({
url: this.host + file.signature,
path: this.path + "/pool"
path: path.join(this.path, "pool")
});
});
return ret;
Expand All @@ -222,7 +222,7 @@ class Client {
var files = [];
urls.forEach((url) => {
files.push({
src: url.path + "/" + path.basename(url.url),
src: path.join(url.path, path.basename(url.url)),
dest: ubuntuPushDir
});
});
Expand Down
16 changes: 8 additions & 8 deletions tests/test-data/file-push.json
@@ -1,34 +1,34 @@
[
{
"dest": "/cache/recovery/",
"src": "./test/pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz"
"src": "test/pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz"
},
{
"dest": "/cache/recovery/",
"src": "./test/pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz.asc"
"src": "test/pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz.asc"
},
{
"dest": "/cache/recovery/",
"src": "./test/pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz"
"src": "test/pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz"
},
{
"dest": "/cache/recovery/",
"src": "./test/pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz.asc"
"src": "test/pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz.asc"
},
{
"dest": "/cache/recovery/",
"src": "./test/pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz"
"src": "test/pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz"
},
{
"dest": "/cache/recovery/",
"src": "./test/pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz.asc"
"src": "test/pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz.asc"
},
{
"dest": "/cache/recovery/",
"src": "./test/pool/version-261.tar.xz"
"src": "test/pool/version-261.tar.xz"
},
{
"dest": "/cache/recovery/",
"src": "./test/pool/version-261.tar.xz.asc"
"src": "test/pool/version-261.tar.xz.asc"
}
]
16 changes: 8 additions & 8 deletions tests/test-data/files-urls.json
@@ -1,38 +1,38 @@
[
{
"checksum": "777b2d05b2a0f26b2a9a302eb7804e7eab9bf536f130ffae2f15455a80bd509b",
"path": "./test/pool",
"path": "test/pool",
"url": "https://system-image.ubports.com//pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz"
},
{
"path": "./test/pool",
"path": "test/pool",
"url": "https://system-image.ubports.com//pool/ubports-e5cf0885f061c9615931cf863a43f65d8590aa71027315ad71999252ce118868.tar.xz.asc"
},
{
"checksum": "234d719a32a01bc36d64dbb536fcf27d77957916f8c3851916e4d1e44d732364",
"path": "./test/pool",
"path": "test/pool",
"url": "https://system-image.ubports.com//pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz"
},
{
"path": "./test/pool",
"path": "test/pool",
"url": "https://system-image.ubports.com//pool/device-f6863fe2f1f8b47cd90f5721af05ccb0ab4d41f2e1cc318075458646eeda28ee.tar.xz.asc"
},
{
"checksum": "5b6e870acf8944330acb2a9dad6f5270bd06c377603a3115f805290e989ab421",
"path": "./test/pool",
"path": "test/pool",
"url": "https://system-image.ubports.com//pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz"
},
{
"path": "./test/pool",
"path": "test/pool",
"url": "https://system-image.ubports.com//pool/keyring-4c4e7ef380ebcfa2c31084efa199138e93bfed8fc58aa3eb06bdf75a78af9b57.tar.xz.asc"
},
{
"checksum": "2624df95cbfc0c0dbdd0ff14a7cf6de78802bb38f5dd2a3fa75f0e99586dcba5",
"path": "./test/pool",
"path": "test/pool",
"url": "https://system-image.ubports.com//ubports-touch/15.04/devel/bacon/version-261.tar.xz"
},
{
"path": "./test/pool",
"path": "test/pool",
"url": "https://system-image.ubports.com//ubports-touch/15.04/devel/bacon/version-261.tar.xz.asc"
}
]
10 changes: 5 additions & 5 deletions tests/unit-tests/test_client.js
Expand Up @@ -136,7 +136,7 @@ describe('Client module', function() {
it("should create install commands file", function() {
const sic = new SystemImageClient();
var file = sic.createInstallCommandsFile(commandfileJson, "bacon");
expect(file.indexOf("./test/commandfile/ubuntu_commandbacon") != -1).to.eql(true);
expect(file.indexOf("test/commandfile/ubuntu_commandbacon") != -1).to.eql(true);
expect(fs.readFileSync(file).toString()).to.eql(commandfileJson);
});
// TODO introduce a test case with invalid input
Expand Down Expand Up @@ -280,10 +280,10 @@ describe('Client module', function() {
it("should return gpg urls array", function() {
const sic = new SystemImageClient();
expect(sic.getGgpUrlsArray()).to.eql([
{ "path": "./test/gpg", "url": "https://system-image.ubports.com/gpg/image-signing.tar.xz" },
{ "path": "./test/gpg", "url": "https://system-image.ubports.com/gpg/image-signing.tar.xz.asc" },
{ "path": "./test/gpg", "url": "https://system-image.ubports.com/gpg/image-master.tar.xz" },
{ "path": "./test/gpg", "url": "https://system-image.ubports.com/gpg/image-master.tar.xz.asc" }
{ "path": "test/gpg", "url": "https://system-image.ubports.com/gpg/image-signing.tar.xz" },
{ "path": "test/gpg", "url": "https://system-image.ubports.com/gpg/image-signing.tar.xz.asc" },
{ "path": "test/gpg", "url": "https://system-image.ubports.com/gpg/image-master.tar.xz" },
{ "path": "test/gpg", "url": "https://system-image.ubports.com/gpg/image-master.tar.xz.asc" }
]);
});
});
Expand Down

0 comments on commit 919af9f

Please sign in to comment.