pretend-platform

Pretend the current process is running on a given platform

ISC 7 个版本
安装
npm install pretend-platform
yarn add pretend-platform
pnpm add pretend-platform
bun add pretend-platform
README

pretend-platform

npm version Build Status Coverage Status

A Node.js module to pretend the current process is running on a given platform

const pretendPlatform = require('pretend-platform');

process.platform; //=> 'darwin'

pretendPlatform('win32');
process.platform; //=> 'win32'

Installation

Use npm.

npm install pretend-platform

API

const pretendPlatform = require('pretend-platform');

pretendPlatform(platform)

platform: string (a platform name to pretend)
Return: string (the pretended platform name)

It modifies process.platform into the given value.

pretendPlatform.restore()

Return: String (pretendPlatform.original)

It restores process.platform to the original value.

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 © 2019 Shinnosuke Watanabe

版本列表
3.0.0-0 2019-02-25
3.0.0 2019-02-28
2.0.2 2019-02-12
2.0.1 2019-02-08
2.0.0 2017-03-09
1.0.1 2015-12-04
1.0.0 2015-11-07