avancement planning
This commit is contained in:
+2
-1
@@ -103,7 +103,7 @@ You can specify the exact backend you wish to use by passing the `backend` optio
|
||||
|
||||
All of the APIs in `@parcel/watcher` support the following options, which are passed as an object as the last function argument.
|
||||
|
||||
- `ignore` - an array of paths or glob patterns to ignore. uses [`is-glob`](https://github.com/micromatch/is-glob) to distinguish paths from globs. glob patterns are parsed with [`micromatch`](https://github.com/micromatch/micromatch) (see [features](https://github.com/micromatch/micromatch#matching-features)).
|
||||
- `ignore` - an array of paths or glob patterns to ignore. uses [`is-glob`](https://github.com/micromatch/is-glob) to distinguish paths from globs. glob patterns are parsed with [`picomatch`](https://github.com/micromatch/picomatch) (see [features](https://github.com/micromatch/picomatch#globbing-features)).
|
||||
- paths can be relative or absolute and can either be files or directories. No events will be emitted about these files or directories or their children.
|
||||
- glob patterns match on relative paths from the root that is watched. No events will be emitted for matching paths.
|
||||
- `backend` - the name of an explicitly chosen backend to use. Allowed options are `"fs-events"`, `"watchman"`, `"inotify"`, `"kqueue"`, `"windows"`, or `"brute-force"` (only for querying). If the specified backend is not available on the current platform, the default backend will be used instead.
|
||||
@@ -129,6 +129,7 @@ subscribe(/* ... */);
|
||||
- [Gatsby Cloud](https://twitter.com/chatsidhartha/status/1435647412828196867)
|
||||
- [Nx](https://nx.dev)
|
||||
- [Nuxt](https://nuxt.com)
|
||||
- [Meteor](https://github.com/meteor/meteor)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
+17
-1
@@ -7,6 +7,7 @@
|
||||
"include_dirs" : ["<!(node -p \"require('node-addon-api').include_dir\")"],
|
||||
'cflags!': [ '-fno-exceptions', '-std=c++17' ],
|
||||
'cflags_cc!': [ '-fno-exceptions', '-std=c++17' ],
|
||||
'cflags': [ '-fstack-protector-strong' ],
|
||||
"conditions": [
|
||||
['OS=="mac"', {
|
||||
"sources": [
|
||||
@@ -65,7 +66,22 @@
|
||||
"msvs_settings": {
|
||||
"VCCLCompilerTool": {
|
||||
"ExceptionHandling": 1, # /EHsc
|
||||
"AdditionalOptions": ['-std:c++17']
|
||||
"AdditionalOptions": [
|
||||
"-std:c++17",
|
||||
"/guard:cf",
|
||||
"/W3",
|
||||
"/we4146",
|
||||
"/w34244",
|
||||
"/we4267",
|
||||
"/sdl",
|
||||
"/ZH:SHA_256"
|
||||
]
|
||||
},
|
||||
"VCLinkerTool": {
|
||||
"AdditionalOptions": [
|
||||
"/DYNAMICBASE",
|
||||
"/guard:cf"
|
||||
]
|
||||
}
|
||||
}
|
||||
}],
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@ const {createWrapper} = require('./wrapper');
|
||||
|
||||
let name = `@parcel/watcher-${process.platform}-${process.arch}`;
|
||||
if (process.platform === 'linux') {
|
||||
const { MUSL, family } = require('detect-libc');
|
||||
const { MUSL, familySync } = require('detect-libc');
|
||||
const family = familySync();
|
||||
if (family === MUSL) {
|
||||
name += '-musl';
|
||||
} else {
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../detect-libc/bin/detect-libc.js" "$@"
|
||||
else
|
||||
exec node "$basedir/../detect-libc/bin/detect-libc.js" "$@"
|
||||
fi
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
.nyc_output
|
||||
.travis.yml
|
||||
coverage
|
||||
test.js
|
||||
node_modules
|
||||
/.circleci
|
||||
/tests/integration
|
||||
-201
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
# detect-libc
|
||||
|
||||
Node.js module to detect the C standard library (libc) implementation
|
||||
family and version in use on a given Linux system.
|
||||
|
||||
Provides a value suitable for use with the `LIBC` option of
|
||||
[prebuild](https://www.npmjs.com/package/prebuild),
|
||||
[prebuild-ci](https://www.npmjs.com/package/prebuild-ci) and
|
||||
[prebuild-install](https://www.npmjs.com/package/prebuild-install),
|
||||
therefore allowing build and provision of pre-compiled binaries
|
||||
for musl-based Linux e.g. Alpine as well as glibc-based.
|
||||
|
||||
Currently supports libc detection of `glibc` and `musl`.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install detect-libc
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### API
|
||||
|
||||
```js
|
||||
const { GLIBC, MUSL, family, version, isNonGlibcLinux } = require('detect-libc');
|
||||
```
|
||||
|
||||
* `GLIBC` is a String containing the value "glibc" for comparison with `family`.
|
||||
* `MUSL` is a String containing the value "musl" for comparison with `family`.
|
||||
* `family` is a String representing the system libc family.
|
||||
* `version` is a String representing the system libc version number.
|
||||
* `isNonGlibcLinux` is a Boolean representing whether the system is a non-glibc Linux, e.g. Alpine.
|
||||
|
||||
### detect-libc command line tool
|
||||
|
||||
When run on a Linux system with a non-glibc libc,
|
||||
the child command will be run with the `LIBC` environment variable
|
||||
set to the relevant value.
|
||||
|
||||
On all other platforms will run the child command as-is.
|
||||
|
||||
The command line feature requires `spawnSync` provided by Node v0.12+.
|
||||
|
||||
```sh
|
||||
detect-libc child-command
|
||||
```
|
||||
|
||||
## Integrating with prebuild
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"install": "detect-libc prebuild-install || node-gyp rebuild",
|
||||
"test": "mocha && detect-libc prebuild-ci"
|
||||
},
|
||||
"dependencies": {
|
||||
"detect-libc": "^1.0.2",
|
||||
"prebuild-install": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prebuild": "^6.2.1",
|
||||
"prebuild-ci": "^2.2.3"
|
||||
}
|
||||
```
|
||||
|
||||
## Licence
|
||||
|
||||
Copyright 2017 Lovell Fuller
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var spawnSync = require('child_process').spawnSync;
|
||||
var libc = require('../');
|
||||
|
||||
var spawnOptions = {
|
||||
env: process.env,
|
||||
shell: true,
|
||||
stdio: 'inherit'
|
||||
};
|
||||
|
||||
if (libc.isNonGlibcLinux) {
|
||||
spawnOptions.env.LIBC = process.env.LIBC || libc.family;
|
||||
}
|
||||
|
||||
process.exit(spawnSync(process.argv[2], process.argv.slice(3), spawnOptions).status);
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var platform = require('os').platform();
|
||||
var spawnSync = require('child_process').spawnSync;
|
||||
var readdirSync = require('fs').readdirSync;
|
||||
|
||||
var GLIBC = 'glibc';
|
||||
var MUSL = 'musl';
|
||||
|
||||
var spawnOptions = {
|
||||
encoding: 'utf8',
|
||||
env: process.env
|
||||
};
|
||||
|
||||
if (!spawnSync) {
|
||||
spawnSync = function () {
|
||||
return { status: 126, stdout: '', stderr: '' };
|
||||
};
|
||||
}
|
||||
|
||||
function contains (needle) {
|
||||
return function (haystack) {
|
||||
return haystack.indexOf(needle) !== -1;
|
||||
};
|
||||
}
|
||||
|
||||
function versionFromMuslLdd (out) {
|
||||
return out.split(/[\r\n]+/)[1].trim().split(/\s/)[1];
|
||||
}
|
||||
|
||||
function safeReaddirSync (path) {
|
||||
try {
|
||||
return readdirSync(path);
|
||||
} catch (e) {}
|
||||
return [];
|
||||
}
|
||||
|
||||
var family = '';
|
||||
var version = '';
|
||||
var method = '';
|
||||
|
||||
if (platform === 'linux') {
|
||||
// Try getconf
|
||||
var glibc = spawnSync('getconf', ['GNU_LIBC_VERSION'], spawnOptions);
|
||||
if (glibc.status === 0) {
|
||||
family = GLIBC;
|
||||
version = glibc.stdout.trim().split(' ')[1];
|
||||
method = 'getconf';
|
||||
} else {
|
||||
// Try ldd
|
||||
var ldd = spawnSync('ldd', ['--version'], spawnOptions);
|
||||
if (ldd.status === 0 && ldd.stdout.indexOf(MUSL) !== -1) {
|
||||
family = MUSL;
|
||||
version = versionFromMuslLdd(ldd.stdout);
|
||||
method = 'ldd';
|
||||
} else if (ldd.status === 1 && ldd.stderr.indexOf(MUSL) !== -1) {
|
||||
family = MUSL;
|
||||
version = versionFromMuslLdd(ldd.stderr);
|
||||
method = 'ldd';
|
||||
} else {
|
||||
// Try filesystem (family only)
|
||||
var lib = safeReaddirSync('/lib');
|
||||
if (lib.some(contains('-linux-gnu'))) {
|
||||
family = GLIBC;
|
||||
method = 'filesystem';
|
||||
} else if (lib.some(contains('libc.musl-'))) {
|
||||
family = MUSL;
|
||||
method = 'filesystem';
|
||||
} else if (lib.some(contains('ld-musl-'))) {
|
||||
family = MUSL;
|
||||
method = 'filesystem';
|
||||
} else {
|
||||
var usrSbin = safeReaddirSync('/usr/sbin');
|
||||
if (usrSbin.some(contains('glibc'))) {
|
||||
family = GLIBC;
|
||||
method = 'filesystem';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isNonGlibcLinux = (family !== '' && family !== GLIBC);
|
||||
|
||||
module.exports = {
|
||||
GLIBC: GLIBC,
|
||||
MUSL: MUSL,
|
||||
family: family,
|
||||
version: version,
|
||||
method: method,
|
||||
isNonGlibcLinux: isNonGlibcLinux
|
||||
};
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"name": "detect-libc",
|
||||
"version": "1.0.3",
|
||||
"description": "Node.js module to detect the C standard library (libc) implementation family and version",
|
||||
"main": "lib/detect-libc.js",
|
||||
"bin": {
|
||||
"detect-libc": "./bin/detect-libc.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "semistandard && nyc --reporter=lcov ava"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/lovell/detect-libc"
|
||||
},
|
||||
"keywords": [
|
||||
"libc",
|
||||
"glibc",
|
||||
"musl"
|
||||
],
|
||||
"author": "Lovell Fuller <npm@lovell.info>",
|
||||
"contributors": [
|
||||
"Niklas Salmoukas <niklas@salmoukas.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"ava": "^0.23.0",
|
||||
"nyc": "^11.3.0",
|
||||
"proxyquire": "^1.8.0",
|
||||
"semistandard": "^11.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
}
|
||||
}
|
||||
+17
-17
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@parcel/watcher",
|
||||
"version": "2.5.1",
|
||||
"version": "2.5.6",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
@@ -50,10 +50,10 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"detect-libc": "^1.0.3",
|
||||
"detect-libc": "^2.0.3",
|
||||
"is-glob": "^4.0.3",
|
||||
"micromatch": "^4.0.5",
|
||||
"node-addon-api": "^7.0.0"
|
||||
"node-addon-api": "^7.0.0",
|
||||
"picomatch": "^4.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.19.8",
|
||||
@@ -71,18 +71,18 @@
|
||||
]
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@parcel/watcher-darwin-x64": "2.5.1",
|
||||
"@parcel/watcher-darwin-arm64": "2.5.1",
|
||||
"@parcel/watcher-win32-x64": "2.5.1",
|
||||
"@parcel/watcher-win32-arm64": "2.5.1",
|
||||
"@parcel/watcher-win32-ia32": "2.5.1",
|
||||
"@parcel/watcher-linux-x64-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-x64-musl": "2.5.1",
|
||||
"@parcel/watcher-linux-arm64-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-arm64-musl": "2.5.1",
|
||||
"@parcel/watcher-linux-arm-glibc": "2.5.1",
|
||||
"@parcel/watcher-linux-arm-musl": "2.5.1",
|
||||
"@parcel/watcher-android-arm64": "2.5.1",
|
||||
"@parcel/watcher-freebsd-x64": "2.5.1"
|
||||
"@parcel/watcher-darwin-x64": "2.5.6",
|
||||
"@parcel/watcher-darwin-arm64": "2.5.6",
|
||||
"@parcel/watcher-win32-x64": "2.5.6",
|
||||
"@parcel/watcher-win32-arm64": "2.5.6",
|
||||
"@parcel/watcher-win32-ia32": "2.5.6",
|
||||
"@parcel/watcher-linux-x64-glibc": "2.5.6",
|
||||
"@parcel/watcher-linux-x64-musl": "2.5.6",
|
||||
"@parcel/watcher-linux-arm64-glibc": "2.5.6",
|
||||
"@parcel/watcher-linux-arm64-musl": "2.5.6",
|
||||
"@parcel/watcher-linux-arm-glibc": "2.5.6",
|
||||
"@parcel/watcher-linux-arm-musl": "2.5.6",
|
||||
"@parcel/watcher-android-arm64": "2.5.6",
|
||||
"@parcel/watcher-freebsd-x64": "2.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
+13
-9
@@ -21,7 +21,11 @@
|
||||
#include "Backend.hh"
|
||||
#include <unordered_map>
|
||||
|
||||
static std::unordered_map<std::string, std::shared_ptr<Backend>> sharedBackends;
|
||||
static std::unordered_map<std::string, std::shared_ptr<Backend>>& getSharedBackends() {
|
||||
static std::unordered_map<std::string, std::shared_ptr<Backend>>* sharedBackends =
|
||||
new std::unordered_map<std::string, std::shared_ptr<Backend>>();
|
||||
return *sharedBackends;
|
||||
}
|
||||
|
||||
std::shared_ptr<Backend> getBackend(std::string backend) {
|
||||
// Use FSEvents on macOS by default.
|
||||
@@ -65,8 +69,8 @@ std::shared_ptr<Backend> getBackend(std::string backend) {
|
||||
}
|
||||
|
||||
std::shared_ptr<Backend> Backend::getShared(std::string backend) {
|
||||
auto found = sharedBackends.find(backend);
|
||||
if (found != sharedBackends.end()) {
|
||||
auto found = getSharedBackends().find(backend);
|
||||
if (found != getSharedBackends().end()) {
|
||||
return found->second;
|
||||
}
|
||||
|
||||
@@ -76,21 +80,21 @@ std::shared_ptr<Backend> Backend::getShared(std::string backend) {
|
||||
}
|
||||
|
||||
result->run();
|
||||
sharedBackends.emplace(backend, result);
|
||||
getSharedBackends().emplace(backend, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void removeShared(Backend *backend) {
|
||||
for (auto it = sharedBackends.begin(); it != sharedBackends.end(); it++) {
|
||||
for (auto it = getSharedBackends().begin(); it != getSharedBackends().end(); it++) {
|
||||
if (it->second.get() == backend) {
|
||||
sharedBackends.erase(it);
|
||||
getSharedBackends().erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Free up memory.
|
||||
if (sharedBackends.size() == 0) {
|
||||
sharedBackends.rehash(0);
|
||||
if (getSharedBackends().size() == 0) {
|
||||
getSharedBackends().rehash(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +149,7 @@ void Backend::watch(WatcherRef watcher) {
|
||||
try {
|
||||
this->subscribe(watcher);
|
||||
mSubscriptions.insert(watcher);
|
||||
} catch (std::exception &err) {
|
||||
} catch (std::exception&) {
|
||||
unref();
|
||||
throw;
|
||||
}
|
||||
|
||||
+28
-16
@@ -1,34 +1,46 @@
|
||||
#include "DirTree.hh"
|
||||
#include <inttypes.h>
|
||||
|
||||
static std::mutex mDirCacheMutex;
|
||||
static std::unordered_map<std::string, std::weak_ptr<DirTree>> dirTreeCache;
|
||||
// "Meyer's singleton", construction is ordered by use, likewise (reverse) for destruction.
|
||||
// https://stackoverflow.com/a/17713799
|
||||
// https://laristra.github.io/flecsi/src/developer-guide/patterns/meyers_singleton.html
|
||||
static std::mutex& mDirCacheMutex() {
|
||||
static std::mutex mutex;
|
||||
return mutex;
|
||||
}
|
||||
|
||||
static std::unordered_map<std::string, std::weak_ptr<DirTree>>& dirTreeCache() {
|
||||
static std::unordered_map<std::string, std::weak_ptr<DirTree>> cache;
|
||||
return cache;
|
||||
}
|
||||
|
||||
struct DirTreeDeleter {
|
||||
void operator()(DirTree *tree) {
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex);
|
||||
dirTreeCache.erase(tree->root);
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex());
|
||||
std::unordered_map<std::string, std::weak_ptr<DirTree>> &cache = dirTreeCache();
|
||||
cache.erase(tree->root);
|
||||
delete tree;
|
||||
|
||||
// Free up memory.
|
||||
if (dirTreeCache.size() == 0) {
|
||||
dirTreeCache.rehash(0);
|
||||
if (cache.size() == 0) {
|
||||
cache.rehash(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::shared_ptr<DirTree> DirTree::getCached(std::string root) {
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex);
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex());
|
||||
std::unordered_map<std::string, std::weak_ptr<DirTree>> &cache = dirTreeCache();
|
||||
|
||||
auto found = dirTreeCache.find(root);
|
||||
auto found = cache.find(root);
|
||||
std::shared_ptr<DirTree> tree;
|
||||
|
||||
// Use cached tree, or create an empty one.
|
||||
if (found != dirTreeCache.end()) {
|
||||
if (found != cache.end()) {
|
||||
tree = found->second.lock();
|
||||
} else {
|
||||
tree = std::shared_ptr<DirTree>(new DirTree(root), DirTreeDeleter());
|
||||
dirTreeCache.emplace(root, tree);
|
||||
cache.emplace(root, tree);
|
||||
}
|
||||
|
||||
return tree;
|
||||
@@ -55,7 +67,7 @@ DirEntry *DirTree::_find(std::string path) {
|
||||
}
|
||||
|
||||
DirEntry *DirTree::add(std::string path, uint64_t mtime, bool isDir) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex());
|
||||
|
||||
DirEntry entry(path, mtime, isDir);
|
||||
auto it = entries.emplace(entry.path, entry);
|
||||
@@ -63,12 +75,12 @@ DirEntry *DirTree::add(std::string path, uint64_t mtime, bool isDir) {
|
||||
}
|
||||
|
||||
DirEntry *DirTree::find(std::string path) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex());
|
||||
return _find(path);
|
||||
}
|
||||
|
||||
DirEntry *DirTree::update(std::string path, uint64_t mtime) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex());
|
||||
|
||||
DirEntry *found = _find(path);
|
||||
if (found) {
|
||||
@@ -79,7 +91,7 @@ DirEntry *DirTree::update(std::string path, uint64_t mtime) {
|
||||
}
|
||||
|
||||
void DirTree::remove(std::string path) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex());
|
||||
|
||||
DirEntry *found = _find(path);
|
||||
|
||||
@@ -99,7 +111,7 @@ void DirTree::remove(std::string path) {
|
||||
}
|
||||
|
||||
void DirTree::write(FILE *f) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex());
|
||||
|
||||
fprintf(f, "%zu\n", entries.size());
|
||||
for (auto it = entries.begin(); it != entries.end(); it++) {
|
||||
@@ -108,7 +120,7 @@ void DirTree::write(FILE *f) {
|
||||
}
|
||||
|
||||
void DirTree::getChanges(DirTree *snapshot, EventList &events) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
std::lock_guard<std::mutex> lock(mDirCacheMutex());
|
||||
std::lock_guard<std::mutex> snapshotLock(snapshot->mMutex);
|
||||
|
||||
for (auto it = entries.begin(); it != entries.end(); it++) {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ struct Glob {
|
||||
Glob(std::string raw);
|
||||
|
||||
bool operator==(const Glob &other) const {
|
||||
return mHash == other.mHash;
|
||||
return mHash == other.mHash && mRaw == other.mRaw;
|
||||
}
|
||||
|
||||
bool isIgnored(std::string relative_path) const;
|
||||
|
||||
+13
-9
@@ -15,30 +15,34 @@ struct WatcherCompare {
|
||||
}
|
||||
};
|
||||
|
||||
static std::unordered_set<WatcherRef , WatcherHash, WatcherCompare> sharedWatchers;
|
||||
static std::unordered_set<WatcherRef , WatcherHash, WatcherCompare>& getSharedWatchers() {
|
||||
static std::unordered_set<WatcherRef , WatcherHash, WatcherCompare>* sharedWatchers =
|
||||
new std::unordered_set<WatcherRef , WatcherHash, WatcherCompare>();
|
||||
return *sharedWatchers;
|
||||
}
|
||||
|
||||
WatcherRef Watcher::getShared(std::string dir, std::unordered_set<std::string> ignorePaths, std::unordered_set<Glob> ignoreGlobs) {
|
||||
WatcherRef watcher = std::make_shared<Watcher>(dir, ignorePaths, ignoreGlobs);
|
||||
auto found = sharedWatchers.find(watcher);
|
||||
if (found != sharedWatchers.end()) {
|
||||
auto found = getSharedWatchers().find(watcher);
|
||||
if (found != getSharedWatchers().end()) {
|
||||
return *found;
|
||||
}
|
||||
|
||||
sharedWatchers.insert(watcher);
|
||||
getSharedWatchers().insert(watcher);
|
||||
return watcher;
|
||||
}
|
||||
|
||||
void removeShared(Watcher *watcher) {
|
||||
for (auto it = sharedWatchers.begin(); it != sharedWatchers.end(); it++) {
|
||||
for (auto it = getSharedWatchers().begin(); it != getSharedWatchers().end(); it++) {
|
||||
if (it->get() == watcher) {
|
||||
sharedWatchers.erase(it);
|
||||
getSharedWatchers().erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Free up memory.
|
||||
if (sharedWatchers.size() == 0) {
|
||||
sharedWatchers.rehash(0);
|
||||
if (getSharedWatchers().size() == 0) {
|
||||
getSharedWatchers().rehash(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +88,7 @@ struct CallbackData {
|
||||
Value callbackEventsToJS(const Env &env, std::vector<Event> &events) {
|
||||
EscapableHandleScope scope(env);
|
||||
Array arr = Array::New(env, events.size());
|
||||
size_t currentEventIndex = 0;
|
||||
uint32_t currentEventIndex = 0;
|
||||
for (auto eventIterator = events.begin(); eventIterator != events.end(); eventIterator++) {
|
||||
arr.Set(currentEventIndex++, eventIterator->toJS(env));
|
||||
}
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ std::unordered_set<std::string> getIgnorePaths(Env env, Value opts) {
|
||||
if (v.IsArray()) {
|
||||
Array items = v.As<Array>();
|
||||
for (size_t i = 0; i < items.Length(); i++) {
|
||||
Value item = items.Get(Number::New(env, i));
|
||||
Value item = items.Get(Number::New(env, static_cast<double>(i)));
|
||||
if (item.IsString()) {
|
||||
result.insert(std::string(item.As<String>().Utf8Value().c_str()));
|
||||
}
|
||||
@@ -37,7 +37,7 @@ std::unordered_set<Glob> getIgnoreGlobs(Env env, Value opts) {
|
||||
if (v.IsArray()) {
|
||||
Array items = v.As<Array>();
|
||||
for (size_t i = 0; i < items.Length(); i++) {
|
||||
Value item = items.Get(Number::New(env, i));
|
||||
Value item = items.Get(Number::New(env, static_cast<double>(i)));
|
||||
if (item.IsString()) {
|
||||
auto key = item.As<String>().Utf8Value();
|
||||
try {
|
||||
@@ -124,7 +124,7 @@ private:
|
||||
Value getResult() override {
|
||||
std::vector<Event> events = watcher->mEvents.getEvents();
|
||||
Array eventsArray = Array::New(env, events.size());
|
||||
size_t i = 0;
|
||||
uint32_t i = 0;
|
||||
for (auto it = events.begin(); it != events.end(); it++) {
|
||||
eventsArray.Set(i++, it->toJS(env));
|
||||
}
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
void execute() override {
|
||||
try {
|
||||
backend->watch(watcher);
|
||||
} catch (std::exception &err) {
|
||||
} catch (std::exception&) {
|
||||
watcher->destroy();
|
||||
throw;
|
||||
}
|
||||
|
||||
+6
-2
@@ -170,7 +170,9 @@ bool InotifyBackend::handleSubscription(struct inotify_event *event, std::shared
|
||||
struct stat st;
|
||||
// Use lstat to avoid resolving symbolic links that we cannot watch anyway
|
||||
// https://github.com/parcel-bundler/watcher/issues/76
|
||||
lstat(path.c_str(), &st);
|
||||
if (lstat(path.c_str(), &st) != 0) {
|
||||
return false;
|
||||
}
|
||||
DirEntry *entry = sub->tree->add(path, CONVERT_TIME(st.st_mtim), S_ISDIR(st.st_mode));
|
||||
|
||||
if (entry->isDir) {
|
||||
@@ -184,7 +186,9 @@ bool InotifyBackend::handleSubscription(struct inotify_event *event, std::shared
|
||||
watcher->mEvents.update(path);
|
||||
|
||||
struct stat st;
|
||||
stat(path.c_str(), &st);
|
||||
if (stat(path.c_str(), &st) != 0) {
|
||||
return false;
|
||||
}
|
||||
sub->tree->update(path, CONVERT_TIME(st.st_mtim));
|
||||
} else if (event->mask & (IN_DELETE | IN_DELETE_SELF | IN_MOVED_FROM | IN_MOVE_SELF)) {
|
||||
bool isSelfEvent = (event->mask & (IN_DELETE_SELF | IN_MOVE_SELF));
|
||||
|
||||
+3
-3
@@ -98,7 +98,7 @@ public:
|
||||
value.push_back(BSER(iss));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BSER::Array arrayValue() override {
|
||||
return value;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
BSERBoolean(bool value) : Value(value) {}
|
||||
bool boolValue() override { return value; }
|
||||
void encode(std::ostream &oss) override {
|
||||
int8_t t = value == true ? BSER_BOOL_TRUE : BSER_BOOL_FALSE;
|
||||
int8_t t = value == true ? static_cast<int8_t>(BSER_BOOL_TRUE) : static_cast<int8_t>(BSER_BOOL_FALSE);
|
||||
oss.write(reinterpret_cast<char*>(&t), sizeof(t));
|
||||
}
|
||||
};
|
||||
@@ -295,7 +295,7 @@ std::string BSER::encode() {
|
||||
|
||||
std::ostringstream res(std::ios_base::binary);
|
||||
res.write("\x00\x01", 2);
|
||||
|
||||
|
||||
BSERInteger(oss.str().size()).encode(res);
|
||||
res << oss.str();
|
||||
return res.str();
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ public:
|
||||
bool success = WriteFile(
|
||||
mPipe, // pipe handle
|
||||
buf.data(), // message
|
||||
buf.size(), // message length
|
||||
static_cast<DWORD>(buf.size()), // message length
|
||||
NULL, // bytes written
|
||||
&overlapped // overlapped
|
||||
);
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
bool success = ReadFile(
|
||||
mPipe, // pipe handle
|
||||
buf, // buffer to receive reply
|
||||
len, // size of buffer
|
||||
static_cast<DWORD>(len), // size of buffer
|
||||
NULL, // number of bytes read
|
||||
&overlapped // overlapped
|
||||
);
|
||||
|
||||
+6
-2
@@ -21,7 +21,7 @@ template<typename T>
|
||||
BSER readBSER(T &&do_read) {
|
||||
std::stringstream oss;
|
||||
char buffer[256];
|
||||
int r;
|
||||
size_t r;
|
||||
int64_t len = -1;
|
||||
do {
|
||||
// Start by reading a minimal amount of data in order to decode the length.
|
||||
@@ -46,7 +46,11 @@ std::string getSockPath() {
|
||||
return std::string(var);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
FILE *fp = popen("watchman --output-encoding=bser get-sockname", "r");
|
||||
#else
|
||||
FILE *fp = popen("watchman --output-encoding=bser get-sockname 2>/dev/null", "r");
|
||||
#endif
|
||||
if (fp == NULL || errno == ECHILD) {
|
||||
throw std::runtime_error("Failed to execute watchman");
|
||||
}
|
||||
@@ -104,7 +108,7 @@ bool WatchmanBackend::checkAvailable() {
|
||||
try {
|
||||
watchmanConnect();
|
||||
return true;
|
||||
} catch (std::exception &err) {
|
||||
} catch (std::exception&) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -5,17 +5,17 @@ std::wstring utf8ToUtf16(std::string input) {
|
||||
WCHAR *output = new WCHAR[len];
|
||||
MultiByteToWideChar(CP_UTF8, 0, input.c_str(), -1, output, len);
|
||||
std::wstring res(output);
|
||||
delete output;
|
||||
delete[] output;
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string utf16ToUtf8(const WCHAR *input, size_t length) {
|
||||
std::string utf16ToUtf8(const WCHAR *input, DWORD length) {
|
||||
unsigned int len = WideCharToMultiByte(CP_UTF8, 0, input, length, NULL, 0, NULL, NULL);
|
||||
char *output = new char[len + 1];
|
||||
WideCharToMultiByte(CP_UTF8, 0, input, length, output, len, NULL, NULL);
|
||||
output[len] = '\0';
|
||||
std::string res(output);
|
||||
delete output;
|
||||
delete[] output;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ std::string normalizePath(std::string path) {
|
||||
std::wstring p = utf8ToUtf16("\\\\?\\" + path);
|
||||
|
||||
// Get the required length for the output
|
||||
unsigned int len = GetLongPathNameW(p.data(), NULL, 0);
|
||||
DWORD len = GetLongPathNameW(p.data(), NULL, 0);
|
||||
if (!len) {
|
||||
return path;
|
||||
}
|
||||
@@ -33,12 +33,12 @@ std::string normalizePath(std::string path) {
|
||||
WCHAR *output = new WCHAR[len];
|
||||
len = GetLongPathNameW(p.data(), output, len);
|
||||
if (!len) {
|
||||
delete output;
|
||||
delete[] output;
|
||||
return path;
|
||||
}
|
||||
|
||||
// Convert back to utf8
|
||||
std::string res = utf16ToUtf8(output + 4, len - 4);
|
||||
delete output;
|
||||
delete[] output;
|
||||
return res;
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
std::wstring utf8ToUtf16(std::string input);
|
||||
std::string utf16ToUtf8(const WCHAR *input, size_t length);
|
||||
std::string utf16ToUtf8(const WCHAR *input, DWORD length);
|
||||
std::string normalizePath(std::string path);
|
||||
|
||||
#endif
|
||||
|
||||
+3
-6
@@ -1,5 +1,5 @@
|
||||
const path = require('path');
|
||||
const micromatch = require('micromatch');
|
||||
const picomatch = require('picomatch');
|
||||
const isGlob = require('is-glob');
|
||||
|
||||
function normalizeOptions(dir, opts = {}) {
|
||||
@@ -14,16 +14,13 @@ function normalizeOptions(dir, opts = {}) {
|
||||
opts.ignoreGlobs = [];
|
||||
}
|
||||
|
||||
const regex = micromatch.makeRe(value, {
|
||||
const regex = picomatch.makeRe(value, {
|
||||
// We set `dot: true` to workaround an issue with the
|
||||
// regular expression on Linux where the resulting
|
||||
// negative lookahead `(?!(\\/|^)` was never matching
|
||||
// in some cases. See also https://bit.ly/3UZlQDm
|
||||
dot: true,
|
||||
// C++ does not support lookbehind regex patterns, they
|
||||
// were only added later to JavaScript engines
|
||||
// (https://bit.ly/3V7S6UL)
|
||||
lookbehinds: false
|
||||
windows: process.platform === 'win32',
|
||||
});
|
||||
opts.ignoreGlobs.push(regex.source);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user