add prettier

This commit is contained in:
Thomas Ruoff
2019-11-14 08:41:27 +01:00
parent 5d945c8f66
commit f4ccfe4429
4 changed files with 56 additions and 45 deletions

14
cli.js
View File

@@ -25,7 +25,9 @@ if (argv.help || argv.h) {
console.log('Detected devices:\n'); console.log('Detected devices:\n');
Object.keys(devices) Object.keys(devices)
.sort(key => !devices[key].connected) .sort(key => !devices[key].connected)
.forEach(key => console.log(key + ':', connectionStatus(devices[key]))); .forEach(key =>
console.log(key + ':', connectionStatus(devices[key]))
);
}); });
} else { } else {
let selectedMonitors = argv._; let selectedMonitors = argv._;
@@ -39,13 +41,19 @@ if (argv.help || argv.h) {
console.log('Using profile', profile); console.log('Using profile', profile);
} }
console.log('Switching on', selectedMonitors.length ? selectedMonitors : 'all connected monitors'); console.log(
'Switching on',
selectedMonitors.length ? selectedMonitors : 'all connected monitors'
);
swm.getDevices((err, devices) => { swm.getDevices((err, devices) => {
if (err) { if (err) {
throw new Error(err); throw new Error(err);
} }
const xrandrOptions = swm.generateXrandrOptions(selectedMonitors, devices); const xrandrOptions = swm.generateXrandrOptions(
selectedMonitors,
devices
);
swm.switchDevices(xrandrOptions); swm.switchDevices(xrandrOptions);
swm.executePostCmd(postCmd); swm.executePostCmd(postCmd);
}); });

View File

@@ -4,7 +4,7 @@ const configPath = require('xdg').basedir.configPath('switchmon/config.json');
const defaults = { const defaults = {
postCmd: undefined, postCmd: undefined,
profiles: {}, profiles: {}
}; };
let config = Object.assign({}, defaults); let config = Object.assign({}, defaults);

View File

@@ -14,10 +14,7 @@
"type": "git", "type": "git",
"url": "git+https://github.com/tomru/switchmon.git" "url": "git+https://github.com/tomru/switchmon.git"
}, },
"keywords": [ "keywords": ["xrandr", "monitor"],
"xrandr",
"monitor"
],
"author": "Thomas Ruoff", "author": "Thomas Ruoff",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
@@ -36,5 +33,9 @@
"mocha-lcov-reporter": "^1.2.0", "mocha-lcov-reporter": "^1.2.0",
"proxyquire": "^1.7.4", "proxyquire": "^1.7.4",
"sinon": "^1.17.3" "sinon": "^1.17.3"
},
"prettier": {
"tabWidth": 4,
"singleQuote": true
} }
} }

6
swm.js
View File

@@ -8,7 +8,9 @@ function executeCmd(cmd, callback) {
} }
function getDevices(callback) { function getDevices(callback) {
executeCmd('xrandr', (err, stdout) => callback(err, err ? null : xrandrParse(stdout))); executeCmd('xrandr', (err, stdout) =>
callback(err, err ? null : xrandrParse(stdout))
);
} }
function switchDevices(xrandrOptions, callback) { function switchDevices(xrandrOptions, callback) {
@@ -23,7 +25,7 @@ function orderDeviceKeys(selectedDevices, devices) {
let orderedDeviceKeys = Object.keys(devices).sort(); let orderedDeviceKeys = Object.keys(devices).sort();
// fix the sort order if monitors were explicitly selected // fix the sort order if monitors were explicitly selected
selectedDevices.reverse().forEach((monitor) => { selectedDevices.reverse().forEach(monitor => {
const index = orderedDeviceKeys.indexOf(monitor); const index = orderedDeviceKeys.indexOf(monitor);
if (index < 0) { if (index < 0) {
console.error('Unkown monitor', monitor, '(ignored)'); console.error('Unkown monitor', monitor, '(ignored)');