├── README.md ├── index.js ├── license └── package.json /README.md: -------------------------------------------------------------------------------- 1 | # cli-clear [![NPM Version](https://img.shields.io/npm/v/cli-clear.svg)](https://npmjs.org/package/cli-clear) 2 | 3 | > Cross-platform terminal screen clear for Node.js 4 | 5 | ANSI escape codes don't always work in Windows. 6 | 7 | ## Getting Started 8 | [Node.js](http://nodejs.org/) `>= 0.8` is required. To install, type this at the command line: 9 | ``` 10 | npm install cli-clear --save-dev 11 | ``` 12 | 13 | ### Usage 14 | ```js 15 | var clear = require("cli-clear"); 16 | 17 | clear(); 18 | ``` 19 | 20 | ## Release History 21 | * 1.0.4 added Node 0.12+ support 22 | * 1.0.3 minor performance enhancements 23 | * 1.0.2 package.json optimization 24 | * 1.0.1 nearly pointless fix 25 | * 1.0.0 fixed extra line break issue 26 | * 0.1.0 initial release 27 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var windows = process.platform.indexOf("win") === 0; 3 | 4 | 5 | 6 | function clear() 7 | { 8 | var i,lines; 9 | var stdout = ""; 10 | 11 | if (windows === false) 12 | { 13 | stdout += "\x1B[2J"; 14 | } 15 | else 16 | { 17 | lines = process.stdout.getWindowSize()[1]; 18 | 19 | for (i=0; i (svachon.com) 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cli-clear", 3 | "description": "Cross-platform terminal screen clear.", 4 | "version": "1.0.4", 5 | "license": "MIT", 6 | "homepage": "https://github.com/stevenvachon/cli-clear", 7 | "author": { 8 | "name": "Steven Vachon", 9 | "email": "contact@svachon.com", 10 | "url": "http://www.svachon.com/" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git://github.com/stevenvachon/cli-clear.git" 15 | }, 16 | "bugs": { 17 | "url": "https://github.com/stevenvachon/cli-clear/issues" 18 | }, 19 | "engines": { 20 | "node": ">= 0.8" 21 | }, 22 | "files": [ 23 | "index.js", 24 | "license" 25 | ], 26 | "keywords": [ 27 | "clear", 28 | "cli", 29 | "cls", 30 | "terminal" 31 | ] 32 | } --------------------------------------------------------------------------------