2015-11-30 18:41:37 +03:00
|
|
|
# windows-mutex
|
|
|
|
|
2023-03-16 13:53:48 +03:00
|
|
|
[![Build Status](https://dev.azure.com/vscode/node-windows-mutex/_apis/build/status/microsoft.node-windows-mutex?branchName=main)](https://dev.azure.com/vscode/node-windows-mutex/_build/latest?definitionId=23&branchName=main)
|
|
|
|
|
|
|
|
[![Build Status](https://dev.azure.com/monacotools/Monaco/_apis/build/status/npm/windows-mutex?repoName=microsoft%2Fnode-windows-mutex&branchName=main)](https://dev.azure.com/monacotools/Monaco/_build/latest?definitionId=464&repoName=microsoft%2Fnode-windows-mutex&branchName=main)
|
|
|
|
|
|
|
|
[![npm version](https://badge.fury.io/js/@vscode/windows-mutex.svg)](https://badge.fury.io/js/@vscode/windows-mutex)
|
2019-07-18 09:22:17 +03:00
|
|
|
|
2015-11-30 18:41:37 +03:00
|
|
|
Expose the Windows CreateMutex API to Node.JS.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2023-03-16 13:53:48 +03:00
|
|
|
`@vscode/windows-mutex` will only compile in Windows machines, so it is advisable
|
2015-11-30 18:41:37 +03:00
|
|
|
to use the `--save-optional` flag and wrap the
|
2023-03-16 13:53:48 +03:00
|
|
|
`require('@vscode/windows-mutex')` call in a `try {} catch {}` block, in case your
|
2015-11-30 18:41:37 +03:00
|
|
|
code also runs on other platforms.
|
|
|
|
|
|
|
|
```
|
2023-03-16 13:53:48 +03:00
|
|
|
npm install --save-optional @vscode/windows-mutex
|
2015-11-30 18:41:37 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```javascript
|
2023-03-16 13:53:48 +03:00
|
|
|
import { Mutex } from '@vscode/windows-mutex';
|
2015-11-30 18:41:37 +03:00
|
|
|
|
2015-11-30 19:36:02 +03:00
|
|
|
var mutex = new Mutex('my-mutex');
|
2015-11-30 18:41:37 +03:00
|
|
|
console.log(mutex.isActive());
|
|
|
|
mutex.release();
|
|
|
|
```
|
2019-07-18 09:28:17 +03:00
|
|
|
|
|
|
|
## Development
|
|
|
|
|
|
|
|
Publishing to NPM is automated via CI. As soon as a tag is pushed to the repo, that version will be built and published to NPM.
|