├── .gitignore ├── CONTRIBUTING.MD ├── LICENSE ├── README.md ├── binding.gyp ├── index.d.ts ├── index.js ├── node-hide-console-window.cc └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | #Webstorm 2 | .idea 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | package-lock.json 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | lib-cov 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # nyc test coverage 22 | .nyc_output 23 | 24 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 25 | .grunt 26 | 27 | # node-waf configuration 28 | .lock-wscript 29 | 30 | # Compiled binary addons (http://nodejs.org/api/addons.html) 31 | build/Release 32 | 33 | # Dependency directories 34 | node_modules 35 | jspm_packages 36 | 37 | # Optional npm cache directory 38 | .npm 39 | 40 | # Optional REPL history 41 | .node_repl_history 42 | 43 | dist 44 | build -------------------------------------------------------------------------------- /CONTRIBUTING.MD: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Edu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [node-hide-console-window](https://www.npmjs.com/package/node-hide-console-window) 2 | 3 | [![Downloads](https://img.shields.io/npm/dt/node-hide-console-window)](https://www.npmjs.com/package/node-hide-console-window) 4 | [![Issues](https://img.shields.io/github/issues/hetrodoo/node-hide-console-window)](https://github.com/hetrodoo/node-hide-console-window/issues) 5 | [![Licence](https://img.shields.io/npm/l/node-hide-console-window)](https://github.com/hetrodoo/node-hide-console-window/blob/master/LICENSE) 6 | 7 | A node module to toggle your app's console window visibility. (Can be used with compilers 8 | like [pkg](https://www.npmjs.com/package/pkg)) 9 | 10 | ### Platforms 11 | 12 | - Windows 13 | 14 | ## What's new in 2.2.0 15 | 16 | - Windows terminal support (thanks to GitHub user [titushm](https://github.com/titushm)) 17 | 18 | ## Warning 19 | 20 | Recently this package have been a victim of a typosquatting attack where some bad actors created a clone of this package 21 | but appended a 's' at the end, **this package isn't and never was compromised**, but if you want you can take a look at the 22 | source code or build it yourself, always check your packages before installing, take care out there! 23 | 24 | ## Installation 25 | 26 | ```bash 27 | yarn add node-hide-console-window 28 | ``` 29 | 30 | or 31 | 32 | ```bash 33 | npm install node-hide-console-window 34 | ``` 35 | 36 | ## Usage 37 | 38 | #### Using import syntax 39 | 40 | ```typescript 41 | import {showConsole, hideConsole} from "node-hide-console-window"; 42 | 43 | //To hide your console just call: 44 | hideConsole(); 45 | 46 | //To show it again use: 47 | showConsole(); 48 | ``` 49 | 50 | #### Using require syntax 51 | 52 | ```typescript 53 | const ConsoleWindow = require("node-hide-console-window"); 54 | 55 | //To hide your console just call: 56 | ConsoleWindow.hideConsole(); 57 | 58 | //To show it again use: 59 | ConsoleWindow.showConsole(); 60 | ``` 61 | 62 | ## Contributing 63 | 64 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 65 | 66 | ## License 67 | 68 | [MIT](https://choosealicense.com/licenses/mit/) 69 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "node-hide-console-window", 5 | "sources": [ "node-hide-console-window.cc" ] 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | declare module "node-hide-console-window" { 2 | function hideConsole(): void 3 | 4 | function showConsole(): void 5 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const {showConsole, hideConsole} = require("./build/Release/node-hide-console-window"); 2 | 3 | module.exports = { 4 | showConsole, 5 | hideConsole 6 | } -------------------------------------------------------------------------------- /node-hide-console-window.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | HWND GetTargetWindow() 5 | { 6 | HWND consoleWindow = GetConsoleWindow(); 7 | HWND parentWindow = GetParent(consoleWindow); 8 | 9 | if (parentWindow == NULL) 10 | { 11 | return consoleWindow; 12 | } 13 | 14 | return parentWindow; 15 | } 16 | 17 | void HideConsole(const v8::FunctionCallbackInfo& args) 18 | { 19 | ShowWindow(GetTargetWindow(), SW_HIDE); 20 | } 21 | 22 | void ShowConsole(const v8::FunctionCallbackInfo& args) 23 | { 24 | ShowWindow(GetTargetWindow(), SW_SHOW); 25 | } 26 | 27 | void Initialize(v8::Local exports) { 28 | NODE_SET_METHOD(exports, "hideConsole", HideConsole); 29 | NODE_SET_METHOD(exports, "showConsole", ShowConsole); 30 | } 31 | 32 | NODE_MODULE(addon, Initialize); 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-hide-console-window", 3 | "version": "2.2.0", 4 | "description": "A node module to toggle your app's console window visibility.", 5 | "main": "index.js", 6 | "author": "hetrodo", 7 | "license": "MIT", 8 | "repository": "https://github.com/hetrodoo/hetrodo-hide-console-window-napi", 9 | "keywords": [ 10 | "Hide", 11 | "Show", 12 | "Window", 13 | "Console", 14 | "Console Window", 15 | "Windows Terminal", 16 | "Terminal" 17 | ], 18 | "os": [ 19 | "win32" 20 | ] 21 | } 22 | --------------------------------------------------------------------------------