From 4ede4fc85a718228a079cdcda48fd4f653675c50 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 27 May 2021 10:54:39 +0700 Subject: [PATCH] Require Node.js 12 --- .github/funding.yml | 4 --- .github/workflows/main.yml | 5 ++-- index.d.ts | 13 +++++----- index.js | 6 ++--- license | 2 +- package.json | 8 +++--- readme.md | 2 +- source/linux/background-managers/cinnamon.js | 4 +-- source/linux/background-managers/dconf.js | 2 +- source/linux/background-managers/dcop.js | 2 +- source/linux/background-managers/feh.js | 2 +- .../linux/background-managers/gconftool-2.js | 2 +- source/linux/background-managers/gnome.js | 2 +- source/linux/background-managers/index.js | 24 +++++++++--------- source/linux/background-managers/mate.js | 4 +-- source/linux/background-managers/nitrogen.js | 2 +- source/linux/background-managers/pcmanfm.js | 2 +- source/linux/background-managers/qdbus.js | 2 +- source/linux/background-managers/setroot.js | 2 +- .../linux/background-managers/xfconf-query.js | 2 +- source/linux/index.js | 2 +- source/linux/util.js | 2 +- ...in-wallpaper.exe => windows-wallpaper.exe} | Bin source/{win.js => windows.js} | 2 +- test.js | 2 +- 25 files changed, 48 insertions(+), 52 deletions(-) delete mode 100644 .github/funding.yml rename source/{win-wallpaper.exe => windows-wallpaper.exe} (100%) rename source/{win.js => windows.js} (89%) diff --git a/.github/funding.yml b/.github/funding.yml deleted file mode 100644 index 15edf6e..0000000 --- a/.github/funding.yml +++ /dev/null @@ -1,4 +0,0 @@ -github: sindresorhus -open_collective: sindresorhus -patreon: sindresorhus -custom: https://sindresorhus.com/donate diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 82d1519..268f715 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,13 +10,12 @@ jobs: fail-fast: false matrix: node-version: + - 16 - 14 - 12 - - 10 - - 8 steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/index.d.ts b/index.d.ts index 3e6035e..24314d4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -37,7 +37,13 @@ declare namespace wallpaper { } } +// eslint-disable-next-line no-redeclare declare const wallpaper: { + // TODO: remove this in the next major version + // when removed, each of the methods in this interface can be refactored to an explicit function export + // and `wallpaper` namespace may be removed completely along with the `export = wallpaper` export. + default: typeof wallpaper; + /** Get the path to the wallpaper image currently set. @@ -104,12 +110,7 @@ declare const wallpaper: { })(); ``` */ - setSolidColor?(rgbHexColor: string, options?: wallpaper.SetOptions): Promise - - // TODO: remove this in the next major version - // when removed, each of the methods in this interface can be refactored to an explicit function export - // and `wallpaper` namespace may be removed completely along with the `export = wallpaper` export. - default: typeof wallpaper; + setSolidColor?(rgbHexColor: string, options?: wallpaper.SetOptions): Promise; }; export = wallpaper; diff --git a/index.js b/index.js index 1c52442..f8cf2a7 100644 --- a/index.js +++ b/index.js @@ -2,11 +2,11 @@ let wallpaper; if (process.platform === 'darwin') { - wallpaper = require('./source/macos'); + wallpaper = require('./source/macos.js'); } else if (process.platform === 'win32') { - wallpaper = require('./source/win'); + wallpaper = require('./source/windows.js'); } else { - wallpaper = require('./source/linux'); + wallpaper = require('./source/linux.js'); } module.exports = wallpaper; diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/package.json b/package.json index 4d368bc..20322dd 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, "engines": { - "node": ">=8" + "node": ">=12" }, "scripts": { "test": "xo && ava && tsd" @@ -33,8 +33,8 @@ ], "devDependencies": { "ava": "^2.1.0", - "tsd": "^0.7.1", - "xo": "^0.24.0" + "tsd": "^0.15.1", + "xo": "^0.39.0" }, "ava": { "serial": true diff --git a/readme.md b/readme.md index b9b5549..d2bef67 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ > Get or set the desktop wallpaper -Works on macOS 10.12+, Linux, and Windows 10+. +Works on macOS 10.14.4+, Linux, and Windows 10+. *Maintainer needed for the Linux part of the code. No new Linux-related changes will be accepted until someone with good Linux knowledge volunteers.* diff --git a/source/linux/background-managers/cinnamon.js b/source/linux/background-managers/cinnamon.js index 3db274f..0999eac 100644 --- a/source/linux/background-managers/cinnamon.js +++ b/source/linux/background-managers/cinnamon.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile, hasLine} = require('../util'); +const {commandExists, execFile, hasLine} = require('../util.js'); exports.isAvailable = async () => { if (!await commandExists('gsettings')) { @@ -9,7 +9,7 @@ exports.isAvailable = async () => { try { const {stdout} = await execFile('gsettings', ['list-schemas']); return hasLine(stdout, 'org.cinnamon.desktop.background'); - } catch (_) { + } catch { return false; } }; diff --git a/source/linux/background-managers/dconf.js b/source/linux/background-managers/dconf.js index c4dc5c3..c0f3025 100644 --- a/source/linux/background-managers/dconf.js +++ b/source/linux/background-managers/dconf.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('dconf'); diff --git a/source/linux/background-managers/dcop.js b/source/linux/background-managers/dcop.js index dc22f3a..cf2e1cb 100644 --- a/source/linux/background-managers/dcop.js +++ b/source/linux/background-managers/dcop.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('dcop'); diff --git a/source/linux/background-managers/feh.js b/source/linux/background-managers/feh.js index 2fd8546..2c1f2a5 100644 --- a/source/linux/background-managers/feh.js +++ b/source/linux/background-managers/feh.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('feh'); diff --git a/source/linux/background-managers/gconftool-2.js b/source/linux/background-managers/gconftool-2.js index e9a12b3..1229cc4 100644 --- a/source/linux/background-managers/gconftool-2.js +++ b/source/linux/background-managers/gconftool-2.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('gconftool-2'); diff --git a/source/linux/background-managers/gnome.js b/source/linux/background-managers/gnome.js index 8f1f4ae..f0dd891 100644 --- a/source/linux/background-managers/gnome.js +++ b/source/linux/background-managers/gnome.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('gsettings'); diff --git a/source/linux/background-managers/index.js b/source/linux/background-managers/index.js index ca654fd..e849062 100644 --- a/source/linux/background-managers/index.js +++ b/source/linux/background-managers/index.js @@ -1,16 +1,16 @@ 'use strict'; module.exports = { - cinnamon: require('./cinnamon'), - dconf: require('./dconf'), - dcop: require('./dcop'), - feh: require('./feh'), - gconftool2: require('./gconftool-2'), - gnome: require('./gnome'), - mate: require('./mate'), - nitrogen: require('./nitrogen'), - pcmanfm: require('./pcmanfm'), - qdbus: require('./qdbus'), - setroot: require('./setroot'), - xfconfquery: require('./xfconf-query') + cinnamon: require('./cinnamon.js'), + dconf: require('./dconf.js'), + dcop: require('./dcop.js'), + feh: require('./feh.js'), + gconftool2: require('./gconftool-2.js'), + gnome: require('./gnome.js'), + mate: require('./mate.js'), + nitrogen: require('./nitrogen.js'), + pcmanfm: require('./pcmanfm.js'), + qdbus: require('./qdbus.js'), + setroot: require('./setroot.js'), + xfconfquery: require('./xfconf-query.js') }; diff --git a/source/linux/background-managers/mate.js b/source/linux/background-managers/mate.js index b24ba22..2efe1e8 100644 --- a/source/linux/background-managers/mate.js +++ b/source/linux/background-managers/mate.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile, hasLine} = require('../util'); +const {commandExists, execFile, hasLine} = require('../util.js'); exports.isAvailable = async () => { if (!await commandExists('gsettings')) { @@ -9,7 +9,7 @@ exports.isAvailable = async () => { try { const {stdout} = await execFile('gsettings', ['list-schemas']); return hasLine(stdout, 'org.mate.background'); - } catch (_) { + } catch { return false; } }; diff --git a/source/linux/background-managers/nitrogen.js b/source/linux/background-managers/nitrogen.js index dbf6697..3986c35 100644 --- a/source/linux/background-managers/nitrogen.js +++ b/source/linux/background-managers/nitrogen.js @@ -1,7 +1,7 @@ 'use strict'; const path = require('path'); const os = require('os'); -const {commandExists, execFile, readFile} = require('../util'); +const {commandExists, execFile, readFile} = require('../util.js'); const homeDir = os.homedir(); diff --git a/source/linux/background-managers/pcmanfm.js b/source/linux/background-managers/pcmanfm.js index 038f02a..fd00eb5 100644 --- a/source/linux/background-managers/pcmanfm.js +++ b/source/linux/background-managers/pcmanfm.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('pcmanfm'); diff --git a/source/linux/background-managers/qdbus.js b/source/linux/background-managers/qdbus.js index a71a84c..1ce4c7f 100644 --- a/source/linux/background-managers/qdbus.js +++ b/source/linux/background-managers/qdbus.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('qdbus'); diff --git a/source/linux/background-managers/setroot.js b/source/linux/background-managers/setroot.js index 41af83d..1f8534b 100644 --- a/source/linux/background-managers/setroot.js +++ b/source/linux/background-managers/setroot.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('setroot'); diff --git a/source/linux/background-managers/xfconf-query.js b/source/linux/background-managers/xfconf-query.js index 4542413..c4e928d 100644 --- a/source/linux/background-managers/xfconf-query.js +++ b/source/linux/background-managers/xfconf-query.js @@ -1,5 +1,5 @@ 'use strict'; -const {commandExists, execFile} = require('../util'); +const {commandExists, execFile} = require('../util.js'); exports.isAvailable = () => commandExists('xfconf-query'); diff --git a/source/linux/index.js b/source/linux/index.js index d55adcf..7374838 100644 --- a/source/linux/index.js +++ b/source/linux/index.js @@ -1,6 +1,6 @@ 'use strict'; const path = require('path'); -const managers = require('./background-managers'); +const managers = require('./background-managers.js'); let availableApps; diff --git a/source/linux/util.js b/source/linux/util.js index 764191a..9ed3e4f 100644 --- a/source/linux/util.js +++ b/source/linux/util.js @@ -16,7 +16,7 @@ exports.commandExists = async cmd => { } return true; - } catch (_) { + } catch { return false; } }; diff --git a/source/win-wallpaper.exe b/source/windows-wallpaper.exe similarity index 100% rename from source/win-wallpaper.exe rename to source/windows-wallpaper.exe diff --git a/source/win.js b/source/windows.js similarity index 89% rename from source/win.js rename to source/windows.js index 7ac1ea3..1a4930d 100644 --- a/source/win.js +++ b/source/windows.js @@ -6,7 +6,7 @@ const childProcess = require('child_process'); const execFile = promisify(childProcess.execFile); // Binary source → https://github.com/sindresorhus/win-wallpaper -const binary = path.join(__dirname, 'win-wallpaper.exe'); +const binary = path.join(__dirname, 'windows-wallpaper.exe'); exports.get = async () => { const {stdout} = await execFile(binary); diff --git a/test.js b/test.js index fc243c1..07db578 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,6 @@ import path from 'path'; import test from 'ava'; -import wallpaper from '.'; +import wallpaper from './index.js'; const MACOS_COLOR_PLACEHOLDER_PATH = '/System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane/Contents/Resources/DesktopPictures.prefPane/Contents/Resources/Transparent.tiff';