-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
280d7bf
commit 12ff7a9
Showing
12 changed files
with
137 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* text=auto | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
var meow = require('meow'); | ||
var stdin = require('get-stdin'); | ||
var trayballoon = require('./'); | ||
import process from 'node:process'; | ||
import meow from 'meow'; | ||
import getStdin from 'get-stdin'; | ||
import trayballoon from './index.js'; | ||
|
||
var cli = meow({ | ||
help: [ | ||
'Usage', | ||
' trayballoon <text>', | ||
' echo <text> | trayballoon', | ||
'', | ||
'Example', | ||
' trayballoon unicorns --title rainbows --icon ponies.ico', | ||
'', | ||
'Options', | ||
' --title Title of the balloon', | ||
' --icon Path to a .ico file or .exe/.dll file with icon resource index', | ||
' --timeout Time to show the balloon in milliseconds', | ||
' --wait Wait for the balloon to disappear' | ||
] | ||
}); | ||
const cli = meow(` | ||
Usage | ||
trayballoon <text> | ||
echo <text> | trayballoon | ||
function init(data) { | ||
Example | ||
trayballoon unicorns --title rainbows --icon ponies.ico | ||
Options | ||
--title Title of the balloon | ||
--icon Path to a .ico file or .exe/.dll file with icon resource index | ||
--timeout Time to show the balloon in milliseconds | ||
--wait Wait for the balloon to disappear | ||
`); | ||
|
||
async function init(data) { | ||
if (!data) { | ||
console.error('Input required'); | ||
process.exit(1); | ||
} | ||
|
||
cli.flags.text = data; | ||
|
||
trayballoon(cli.flags, function (err) { | ||
if (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
}); | ||
if (cli.flags.wait) { | ||
await trayballoon(cli.flags); | ||
} else { | ||
trayballoon(cli.flags); | ||
} | ||
} | ||
|
||
if (process.stdin.isTTY) { | ||
init(cli.input[0]); | ||
} else { | ||
stdin(init); | ||
} | ||
(async () => { | ||
if (process.stdin.isTTY) { | ||
await init(cli.input[0]); | ||
} else { | ||
const stdin = await getStdin(); | ||
await init(stdin); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,27 @@ | ||
'use strict'; | ||
var path = require('path'); | ||
var nircmd = require('nircmd'); | ||
var onetime = require('onetime'); | ||
var objectAssign = require('object-assign'); | ||
|
||
module.exports = function (opts, cb) { | ||
if (typeof opts !== 'object') { | ||
cb = opts; | ||
opts = {}; | ||
} | ||
|
||
opts = objectAssign({}, opts); | ||
var reIsBinResource = /^[^\.]+\.(?:exe|dll),-\d+$/; | ||
|
||
// only wait when there's a callback | ||
opts.wait = Boolean(cb) && opts.wait === true || false; | ||
|
||
opts.icon = opts.icon || ''; | ||
opts.icon = reIsBinResource.test(opts.icon) ? opts.icon : path.resolve(opts.icon); | ||
opts.timeout = typeof opts.timeout === 'number' ? opts.timeout : 5000; | ||
|
||
cb = cb || function () {}; | ||
cb = onetime(cb); | ||
import process from 'node:process'; | ||
import path from 'node:path'; | ||
import nircmd from 'nircmd'; | ||
|
||
export default async function trayballoon(options = {}) { | ||
if (process.platform !== 'win32') { | ||
throw new Error('Only works on Windows'); | ||
} | ||
|
||
if (!opts.text) { | ||
throw new Error('`text` option is required'); | ||
if (!options.text) { | ||
throw new Error('The `text` option is required'); | ||
} | ||
|
||
var args = [ | ||
'trayballoon', | ||
opts.title || ' ', | ||
opts.text, | ||
opts.icon || ' ', | ||
opts.timeout | ||
]; | ||
const reIsBinResource = /^[^.]+\.(?:exe|dll),-\d+$/; | ||
|
||
var cpOpts = { | ||
cwd: path.join(__dirname, 'vendor') | ||
}; | ||
options.icon = options.icon || ''; | ||
options.icon = reIsBinResource.test(options.icon) ? options.icon : path.resolve(options.icon); | ||
options.timeout = typeof options.timeout === 'number' ? options.timeout : 5000; | ||
|
||
if (!opts.wait) { | ||
cpOpts.detached = true; | ||
cpOpts.stdio = ['ignore', 'ignore', process.stderr]; | ||
} | ||
|
||
var cp = nircmd.spawn(args, cpOpts); | ||
|
||
cp.once('error', cb); | ||
cp.once('close', function (code) { | ||
// NirCmd exits with this weird code even though it worked | ||
cb(code === 4207175 ? 0 : code); | ||
}); | ||
|
||
// make sure the callback is called, after a possible `exit` event, | ||
// since unref()'ing the process makes it not call the `close` event | ||
if (!opts.wait) { | ||
cp.unref(); | ||
setImmediate(cb); | ||
} | ||
}; | ||
await nircmd([ | ||
'trayballoon', | ||
options.title || ' ', | ||
options.text, | ||
options.icon || ' ', | ||
options.timeout, | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,9 @@ | ||
The MIT License (MIT) | ||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | ||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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: | ||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
{ | ||
"name": "trayballoon", | ||
"version": "1.0.4", | ||
"description": "Create a trayballoon on Windows", | ||
"license": "MIT", | ||
"repository": "sindresorhus/trayballoon", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"bin": "cli.js", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "ava" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"cli.js" | ||
], | ||
"keywords": [ | ||
"cli-app", | ||
"cli", | ||
"bin", | ||
"trayballoon", | ||
"tray", | ||
"balloon", | ||
"tip", | ||
"tooltip", | ||
"popup", | ||
"popover", | ||
"windows", | ||
"win", | ||
"notification" | ||
], | ||
"dependencies": { | ||
"get-stdin": "^4.0.1", | ||
"meow": "^3.3.0", | ||
"nircmd": "^1.2.1", | ||
"object-assign": "^2.0.0", | ||
"onetime": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*" | ||
} | ||
"name": "trayballoon", | ||
"version": "1.0.4", | ||
"description": "Create a trayballoon on Windows", | ||
"license": "MIT", | ||
"repository": "sindresorhus/trayballoon", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"bin": "./cli.js", | ||
"engines": { | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"cli.js" | ||
], | ||
"keywords": [ | ||
"cli-app", | ||
"cli", | ||
"trayballoon", | ||
"tray", | ||
"balloon", | ||
"tip", | ||
"tooltip", | ||
"popup", | ||
"popover", | ||
"windows", | ||
"notification" | ||
], | ||
"dependencies": { | ||
"get-stdin": "^9.0.0", | ||
"meow": "^10.1.1", | ||
"nircmd": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
Oops, something went wrong.