Updates after package updates
This commit is contained in:
parent
92ba4af306
commit
1914641b77
|
@ -239,7 +239,7 @@ button:focus {
|
||||||
width: 7px;
|
width: 7px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: calc(22%);
|
left: calc(50% - (14px * 2));
|
||||||
}
|
}
|
||||||
.dial-end {
|
.dial-end {
|
||||||
transform: rotateZ(0deg);
|
transform: rotateZ(0deg);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs-extra');
|
||||||
const settings = {};
|
const settings = {};
|
||||||
|
|
||||||
settings.file = path.join(os.homedir(), `/.mcopy/settings.json`);
|
settings.file = path.join(os.homedir(), `/.mcopy/settings.json`);
|
||||||
|
@ -16,55 +16,73 @@ settings.state = {
|
||||||
light : {}
|
light : {}
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.checkDir = function () {
|
settings.checkDir = async function () {
|
||||||
'use strict'
|
'use strict';
|
||||||
const dir = path.join(os.homedir(), '.mcopy/');
|
const dir = path.join(os.homedir(), '.mcopy/');
|
||||||
if (!fs.existsSync(dir)) {
|
const exists = await fs.exists(dir)
|
||||||
fs.mkdirSync(dir);
|
if (!exists) {
|
||||||
|
try {
|
||||||
|
await fs.mkdir(dir);
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code === 'EEXIST') return true
|
||||||
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
settings.save = function () {
|
settings.save = async function () {
|
||||||
'use strict'
|
'use strict';
|
||||||
const str = JSON.stringify(settings.state, null, '\t');
|
const str = JSON.stringify(settings.state, null, '\t');
|
||||||
settings.checkDir();
|
settings.checkDir();
|
||||||
fs.writeFile(settings.file, str, 'utf8', (err) => {
|
try {
|
||||||
if (err) console.error(err);
|
await fs.writeFile(settings.file, str, 'utf8');
|
||||||
})
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
settings.update = function (key, val) {
|
settings.update = function (key, val) {
|
||||||
'use strict'
|
'use strict';
|
||||||
settings.state[key] = val;
|
settings.state[key] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.get = function (key) {
|
settings.get = function (key) {
|
||||||
'use strict'
|
'use strict';
|
||||||
return settings.state[key];
|
return settings.state[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.all = function () {
|
settings.all = function () {
|
||||||
'use strict'
|
'use strict';
|
||||||
return settings.state;
|
return settings.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.restore = function () {
|
settings.restore = async function () {
|
||||||
'use strict'
|
'use strict';
|
||||||
|
let exists;
|
||||||
let str;
|
let str;
|
||||||
|
|
||||||
settings.checkDir();
|
settings.checkDir();
|
||||||
if (fs.existsSync(settings.file)) {
|
exists = await fs.exists(settings.file);
|
||||||
str = fs.readFileSync(settings.file, 'utf8')
|
|
||||||
|
if (exists) {
|
||||||
|
str = await fs.readFile(settings.file, 'utf8');
|
||||||
settings.state = JSON.parse(str);
|
settings.state = JSON.parse(str);
|
||||||
} else {
|
} else {
|
||||||
settings.save();
|
settings.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.reset = function () {
|
settings.reset = async function () {
|
||||||
'use strict'
|
'use strict';
|
||||||
if (fs.existsSync(settings.file)) {
|
const exists = await fs.exists(settings.file);
|
||||||
fs.unlinkSync(settings.file);
|
if (exists) {
|
||||||
|
try {
|
||||||
|
await fs.unlink(settings.file);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
settings.restore();
|
settings.restore();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = settings
|
module.exports = settings;
|
|
@ -600,7 +600,7 @@ log.file = function () {
|
||||||
return path.join(logPath, 'mcopy.log')
|
return path.join(logPath, 'mcopy.log')
|
||||||
}
|
}
|
||||||
log.time = 'MM/DD/YY-HH:mm:ss'
|
log.time = 'MM/DD/YY-HH:mm:ss'
|
||||||
log.transport = new (winston.Logger)({
|
log.transport = winston.createLogger({
|
||||||
transports: [
|
transports: [
|
||||||
new (winston.transports.Console)(),
|
new (winston.transports.Console)(),
|
||||||
new (winston.transports.File)({ filename: log.file() })
|
new (winston.transports.File)({ filename: log.file() })
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy-app",
|
"name": "mcopy-app",
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"description": "Small guage film optical printer platform",
|
"description": "Small guage film optical printer platform",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in New Issue