Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/pretend-platform
Pretend the current process is running on a given platform
https://github.com/shinnn/pretend-platform
Last synced: 26 days ago
JSON representation
Pretend the current process is running on a given platform
- Host: GitHub
- URL: https://github.com/shinnn/pretend-platform
- Owner: shinnn
- License: isc
- Created: 2015-11-07T20:11:11.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-02-28T12:33:27.000Z (over 5 years ago)
- Last Synced: 2024-04-27T03:43:19.639Z (7 months ago)
- Language: JavaScript
- Size: 89.8 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pretend-platform
[![npm version](https://img.shields.io/npm/v/pretend-platform.svg)](https://www.npmjs.com/package/pretend-platform)
[![Build Status](https://travis-ci.com/shinnn/pretend-platform.svg?branch=master)](https://travis-ci.com/shinnn/pretend-platform)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/pretend-platform.svg)](https://coveralls.io/github/shinnn/pretend-platform)A [Node.js](https://nodejs.org/) module to pretend the current process is running on a given platform
```javascript
const pretendPlatform = require('pretend-platform');process.platform; //=> 'darwin'
pretendPlatform('win32');
process.platform; //=> 'win32'
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).
```
npm install pretend-platform
```## API
```javascript
const pretendPlatform = require('pretend-platform');
```### pretendPlatform(*platform*)
*platform*: `string` (a platform name to pretend)
Return: `string` (the pretended platform name)It modifies [`process.platform`](https://nodejs.org/api/process.html#process_process_platform) into the given value.
### pretendPlatform.restore()
Return: `String` ([`pretendPlatform.original`](#pretendplatformoriginal))
It restores `process.platform` to the original value.
```javascript
const pretendPlatform = require('pretend-platform');process.platform; //=> 'linux'
pretendPlatform('freebsd');
process.platform; //=> 'freebsd'pretendPlatform.restore();
process.platform; //=> 'linux'
```### pretendPlatform.original
Type: `string`
The read-only property preserving the original `process.platform`.
## License
[ISC License](./LICENSE) © 2019 Shinnosuke Watanabe