use eslint to fix indentation of app loader js

master
Gordon Williams 2020-05-27 16:51:14 +01:00
parent 765be3ef40
commit 2fd2caaacc
7 changed files with 291 additions and 284 deletions

1
js/.eslintignore Normal file
View File

@ -0,0 +1 @@
espruinotools.js

View File

@ -4,7 +4,13 @@
"sourceType": "script"
},
"rules": {
"indent": [
"warn",
2,
{
"SwitchCase": 1
}
]
},
"env": {
"browser": true,

View File

@ -2,13 +2,13 @@ Puck.debug=3;
// FIXME: use UART lib so that we handle errors properly
var Comms = {
reset : (opt) => new Promise((resolve,reject) => {
reset : (opt) => new Promise((resolve,reject) => {
Puck.write(`\x03\x10reset(${opt=="wipe"?"1":""});\n`, (result) => {
if (result===null) return reject("Connection failed");
setTimeout(resolve,500);
});
}),
uploadApp : (app,skipReset) => { // expects an apps.json structure (i.e. with `storage`)
}),
uploadApp : (app,skipReset) => { // expects an apps.json structure (i.e. with `storage`)
Progress.show({title:`Uploading ${app.name}`,sticky:true});
return AppInfo.getFiles(app, {
fileGetter : httpGet,
@ -75,8 +75,8 @@ uploadApp : (app,skipReset) => { // expects an apps.json structure (i.e. with `s
}
});
});
},
getInstalledApps : () => {
},
getInstalledApps : () => {
Progress.show({title:`Getting app list...`,sticky:true});
return new Promise((resolve,reject) => {
Puck.write("\x03",(result) => {
@ -101,8 +101,8 @@ getInstalledApps : () => {
}, true /* callback on newline */);
});
});
},
removeApp : app => { // expects an appid.info structure (i.e. with `files`)
},
removeApp : app => { // expects an appid.info structure (i.e. with `files`)
if (!app.files && !app.data) return Promise.resolve(); // nothing to erase
Progress.show({title:`Removing ${app.name}`,sticky:true});
let cmds = '\x10const s=require("Storage");\n';
@ -138,8 +138,8 @@ removeApp : app => { // expects an appid.info structure (i.e. with `files`)
Progress.hide({sticky:true});
return Promise.reject(reason);
});
},
removeAllApps : () => {
},
removeAllApps : () => {
Progress.show({title:"Removing all apps",progess:"animate",sticky:true});
return new Promise((resolve,reject) => {
// Use write with newline here so we wait for it to finish
@ -149,8 +149,8 @@ removeAllApps : () => {
resolve();
}, true /* wait for newline */);
});
},
setTime : () => {
},
setTime : () => {
return new Promise((resolve,reject) => {
var d = new Date();
var tz = d.getTimezoneOffset()/-60
@ -163,15 +163,15 @@ setTime : () => {
resolve();
});
});
},
disconnectDevice: () => {
},
disconnectDevice: () => {
var connection = Puck.getConnection();
if (!connection) return;
connection.close();
},
watchConnectionChange : cb => {
},
watchConnectionChange : cb => {
var connected = Puck.isConnected();
//TODO Switch to an event listener when Puck will support it
@ -186,8 +186,8 @@ watchConnectionChange : cb => {
return () => {
clearInterval(interval);
};
},
listFiles : () => {
},
listFiles : () => {
return new Promise((resolve,reject) => {
Puck.write("\x03",(result) => {
if (result===null) return reject("");
@ -200,8 +200,8 @@ listFiles : () => {
});
});
});
},
readFile : (file) => {
},
readFile : (file) => {
return new Promise((resolve,reject) => {
//encode name to avoid serialization issue due to octal sequence
const name = encodeURIComponent(file);
@ -216,8 +216,8 @@ readFile : (file) => {
});
});
});
},
readStorageFile : (filename) => { // StorageFiles are different to normal storage entries
},
readStorageFile : (filename) => { // StorageFiles are different to normal storage entries
return new Promise((resolve,reject) => {
// Use "\xFF" to signal end of file (can't occur in files anyway)
var fileContent = "";
@ -261,5 +261,5 @@ readStorageFile : (filename) => { // StorageFiles are different to normal storag
console.log(`StorageFile read started...`);
});
});
}
}
};