Updates after package updates

This commit is contained in:
mmcw-dev 2018-09-02 14:26:12 -04:00
parent 92ba4af306
commit 1914641b77
4 changed files with 43 additions and 25 deletions

View File

@ -239,7 +239,7 @@ button:focus {
width: 7px;
position: absolute;
top: 0;
left: calc(22%);
left: calc(50% - (14px * 2));
}
.dial-end {
transform: rotateZ(0deg);

View File

@ -1,6 +1,6 @@
const os = require('os');
const path = require('path');
const fs = require('fs');
const fs = require('fs-extra');
const settings = {};
settings.file = path.join(os.homedir(), `/.mcopy/settings.json`);
@ -16,55 +16,73 @@ settings.state = {
light : {}
}
settings.checkDir = function () {
'use strict'
settings.checkDir = async function () {
'use strict';
const dir = path.join(os.homedir(), '.mcopy/');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
const exists = await fs.exists(dir)
if (!exists) {
try {
await fs.mkdir(dir);
} catch (err) {
if (err.code === 'EEXIST') return true
console.error(err);
}
}
return true
}
settings.save = function () {
'use strict'
settings.save = async function () {
'use strict';
const str = JSON.stringify(settings.state, null, '\t');
settings.checkDir();
fs.writeFile(settings.file, str, 'utf8', (err) => {
if (err) console.error(err);
})
try {
await fs.writeFile(settings.file, str, 'utf8');
} catch (err) {
console.error(err);
}
}
settings.update = function (key, val) {
'use strict'
'use strict';
settings.state[key] = val;
}
settings.get = function (key) {
'use strict'
'use strict';
return settings.state[key];
}
settings.all = function () {
'use strict'
'use strict';
return settings.state;
}
settings.restore = function () {
'use strict'
settings.restore = async function () {
'use strict';
let exists;
let str;
settings.checkDir();
if (fs.existsSync(settings.file)) {
str = fs.readFileSync(settings.file, 'utf8')
exists = await fs.exists(settings.file);
if (exists) {
str = await fs.readFile(settings.file, 'utf8');
settings.state = JSON.parse(str);
} else {
settings.save();
}
}
settings.reset = function () {
'use strict'
if (fs.existsSync(settings.file)) {
fs.unlinkSync(settings.file);
settings.reset = async function () {
'use strict';
const exists = await fs.exists(settings.file);
if (exists) {
try {
await fs.unlink(settings.file);
} catch (err) {
console.error(err);
}
}
settings.restore();
};
module.exports = settings
module.exports = settings;

View File

@ -600,7 +600,7 @@ log.file = function () {
return path.join(logPath, 'mcopy.log')
}
log.time = 'MM/DD/YY-HH:mm:ss'
log.transport = new (winston.Logger)({
log.transport = winston.createLogger({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: log.file() })

View File

@ -1,6 +1,6 @@
{
"name": "mcopy-app",
"version": "1.0.3",
"version": "1.1.0",
"description": "Small guage film optical printer platform",
"main": "main.js",
"scripts": {