mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 13:14:44 +00:00
.
This commit is contained in:
parent
beb1329f9f
commit
2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
55
node_modules/@cnakazawa/watch/LICENSE
generated
vendored
Normal file
55
node_modules/@cnakazawa/watch/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
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:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
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
|
||||
|
||||
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
|
153
node_modules/@cnakazawa/watch/README.md
generated
vendored
Normal file
153
node_modules/@cnakazawa/watch/README.md
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
# watch -- Utilities for watching file trees in node.js
|
||||
|
||||
## Install
|
||||
|
||||
<pre>
|
||||
npm install watch
|
||||
</pre>
|
||||
|
||||
## Purpose
|
||||
|
||||
The intention of this module is provide tools that make managing the watching of file & directory trees easier.
|
||||
|
||||
#### watch.watchTree(root, [options,] callback)
|
||||
|
||||
The first argument is the directory root you want to watch.
|
||||
|
||||
The options object is passed to fs.watchFile but can also be used to provide two additional watchTree specific options:
|
||||
|
||||
* `'ignoreDotFiles'` - When true this option means that when the file tree is walked it will ignore files that being with "."
|
||||
* `'filter'` - You can use this option to provide a function that returns true or false for each file and directory to decide whether or not that file/directory is included in the watcher.
|
||||
* `'interval'` - Specifies the interval duration in seconds, the time period between polling for file changes.
|
||||
* `'ignoreUnreadableDir'` - When true, this options means that when a file can't be read, this file is silently skipped.
|
||||
* `'ignoreNotPermitted'` - When true, this options means that when a file can't be read due to permission issues, this file is silently skipped.
|
||||
* `'ignoreDirectoryPattern'` - When a regex pattern is set, e.g. /node_modules/, these directories are silently skipped.
|
||||
|
||||
The callback takes 3 arguments. The first is the file that was modified. The second is the current stat object for that file and the third is the previous stat object.
|
||||
|
||||
When a file is new the previous stat object is null.
|
||||
|
||||
When watchTree is finished walking the tree and adding all the listeners it passes the file hash (keys are the file/directory names and the values are the current stat objects) as the first argument and null as both the previous and current stat object arguments.
|
||||
|
||||
<pre>
|
||||
watch.watchTree('/home/mikeal', function (f, curr, prev) {
|
||||
if (typeof f == "object" && prev === null && curr === null) {
|
||||
// Finished walking the tree
|
||||
} else if (prev === null) {
|
||||
// f is a new file
|
||||
} else if (curr.nlink === 0) {
|
||||
// f was removed
|
||||
} else {
|
||||
// f was changed
|
||||
}
|
||||
})
|
||||
</pre>
|
||||
|
||||
### watch.unwatchTree(root)
|
||||
|
||||
Unwatch a previously watched directory root using `watch.watchTree`.
|
||||
|
||||
### watch.createMonitor(root, [options,] callback)
|
||||
|
||||
This function creates an EventEmitter that gives notifications for different changes that happen to the file and directory tree under the given root argument.
|
||||
|
||||
The options object is passed to watch.watchTree.
|
||||
|
||||
The callback receives the monitor object.
|
||||
|
||||
The monitor object contains a property, `files`, which is a hash of files and directories as keys with the current stat object as the value.
|
||||
|
||||
The monitor has the following events.
|
||||
|
||||
* `'created'` - New file has been created. Two arguments, the filename and the stat object.
|
||||
* `'removed'` - A file has been moved or deleted. Two arguments, the filename and the stat object for the fd.
|
||||
* `'changed'` - A file has been changed. Three arguments, the filename, the current stat object, and the previous stat object.
|
||||
|
||||
The monitor can be stopped using `.stop` (calls `unwatchTree`).
|
||||
|
||||
<pre>
|
||||
var watch = require('watch')
|
||||
watch.createMonitor('/home/mikeal', function (monitor) {
|
||||
monitor.files['/home/mikeal/.zshrc'] // Stat object for my zshrc.
|
||||
monitor.on("created", function (f, stat) {
|
||||
// Handle new files
|
||||
})
|
||||
monitor.on("changed", function (f, curr, prev) {
|
||||
// Handle file changes
|
||||
})
|
||||
monitor.on("removed", function (f, stat) {
|
||||
// Handle removed files
|
||||
})
|
||||
monitor.stop(); // Stop watching
|
||||
})
|
||||
</pre>
|
||||
|
||||
### CLI
|
||||
|
||||
This module includes a simple command line interface, which you can install with `npm install watch -g`.
|
||||
|
||||
|
||||
```
|
||||
Usage: watch <command> [...directory] [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--wait=<seconds>
|
||||
Duration, in seconds, that watching will be disabled
|
||||
after running <command>. Setting this option will
|
||||
throttle calls to <command> for the specified duration.
|
||||
|
||||
--filter=<file>
|
||||
Path to a require-able .js file that exports a filter
|
||||
function to be passed to watchTreeOptions.filter.
|
||||
Path is resolved relative to process.cwd().
|
||||
|
||||
--interval=<seconds>
|
||||
Specifies the interval duration in seconds, the time period between polling for file changes.
|
||||
|
||||
--ignoreDotFiles, -d
|
||||
Ignores dot or hidden files in the watch [directory].
|
||||
|
||||
--ignoreUnreadable, -u
|
||||
Silently ignores files that cannot be read within the
|
||||
watch [directory].
|
||||
|
||||
--ignoreDirectoryPattern=<regexp>, -p
|
||||
Silently skips directories that match the regular
|
||||
expression.
|
||||
```
|
||||
|
||||
It will watch the given directories (defaults to the current working directory) with `watchTree` and run the given command every time a file changes.
|
||||
|
||||
### Examples
|
||||
|
||||
As stated above the pattern is:
|
||||
|
||||
watch <command> [...directory] [OPTIONS]
|
||||
|
||||
To run the watch command in the terminal you have to write the following:
|
||||
|
||||
watch 'npm run test -s' directory
|
||||
|
||||
As the command has to be written in quotation marks Windows users may need to use double quotes rather than single quotes
|
||||
|
||||
watch "npm run test -s" directory
|
||||
|
||||
Note: Because Windows users may need to use double quotes rather than single quotes they need to escape the them in npm scripts
|
||||
|
||||
"scripts": {
|
||||
"watch:osx": "watch 'npm run test -s' source"
|
||||
"watch:windows": "watch \"npm run test -s\" source",
|
||||
}
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
### Releasing
|
||||
|
||||
On the latest clean `master`:
|
||||
|
||||
```
|
||||
npm run release:major
|
||||
npm run release:minor
|
||||
npm run release:patch
|
||||
```
|
83
node_modules/@cnakazawa/watch/cli.js
generated
vendored
Executable file
83
node_modules/@cnakazawa/watch/cli.js
generated
vendored
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
var argv = require('minimist')(process.argv.slice(2))
|
||||
var execshell = require('exec-sh')
|
||||
var path = require('path')
|
||||
var watch = require('./main.js')
|
||||
|
||||
if(argv._.length === 0) {
|
||||
console.error([
|
||||
'Usage: watch <command> [...directory]',
|
||||
'[--wait=<seconds>]',
|
||||
'[--filter=<file>]',
|
||||
'[--interval=<seconds>]',
|
||||
'[--ignoreDotFiles]',
|
||||
'[--ignoreUnreadable]',
|
||||
'[--ignoreDirectoryPattern]'
|
||||
].join(' '))
|
||||
process.exit()
|
||||
}
|
||||
|
||||
var watchTreeOpts = {}
|
||||
var command = argv._[0]
|
||||
var dirs = []
|
||||
|
||||
var i
|
||||
var argLen = argv._.length
|
||||
if (argLen > 1) {
|
||||
for(i = 1; i< argLen; i++) {
|
||||
dirs.push(argv._[i])
|
||||
}
|
||||
} else {
|
||||
dirs.push(process.cwd())
|
||||
}
|
||||
|
||||
var waitTime = Number(argv.wait || argv.w)
|
||||
if (argv.interval || argv.i) {
|
||||
watchTreeOpts.interval = Number(argv.interval || argv.i || 0.2);
|
||||
}
|
||||
|
||||
if(argv.ignoreDotFiles || argv.d)
|
||||
watchTreeOpts.ignoreDotFiles = true
|
||||
|
||||
if(argv.ignoreUnreadable || argv.u)
|
||||
watchTreeOpts.ignoreUnreadableDir = true
|
||||
|
||||
if(argv.ignoreDirectoryPattern || argv.p) {
|
||||
var match = (argv.ignoreDirectoryPattern || argv.p).match(/^\/(.*)\/([gimuy]*)$/);
|
||||
watchTreeOpts.ignoreDirectoryPattern = new RegExp(match[1], match[2])
|
||||
}
|
||||
|
||||
if(argv.filter || argv.f) {
|
||||
try {
|
||||
watchTreeOpts.filter = require(path.resolve(process.cwd(), argv.filter || argv.f))
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
var wait = false
|
||||
|
||||
var dirLen = dirs.length
|
||||
var skip = dirLen - 1
|
||||
for(i = 0; i < dirLen; i++) {
|
||||
var dir = dirs[i]
|
||||
console.error('> Watching', dir)
|
||||
watch.watchTree(dir, watchTreeOpts, function (f, curr, prev) {
|
||||
if(skip) {
|
||||
skip--
|
||||
return
|
||||
}
|
||||
if(wait) return
|
||||
|
||||
execshell(command)
|
||||
|
||||
if(waitTime > 0) {
|
||||
wait = true
|
||||
setTimeout(function () {
|
||||
wait = false
|
||||
}, waitTime * 1000)
|
||||
}
|
||||
})
|
||||
}
|
168
node_modules/@cnakazawa/watch/main.js
generated
vendored
Normal file
168
node_modules/@cnakazawa/watch/main.js
generated
vendored
Normal file
|
@ -0,0 +1,168 @@
|
|||
// Copyright 2010-2011 Mikeal Rogers
|
||||
//
|
||||
// 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.
|
||||
|
||||
var sys = require('util')
|
||||
, fs = require('fs')
|
||||
, path = require('path')
|
||||
, events = require('events')
|
||||
;
|
||||
|
||||
function walk (dir, options, callback) {
|
||||
if (!callback) {callback = options; options = {}}
|
||||
if (!callback.files) callback.files = {};
|
||||
if (!callback.pending) callback.pending = 0;
|
||||
callback.pending += 1;
|
||||
fs.stat(dir, function (err, stat) {
|
||||
if (err) return callback(err);
|
||||
callback.files[dir] = stat;
|
||||
fs.readdir(dir, function (err, files) {
|
||||
if (err) {
|
||||
if(err.code === 'EACCES' && options.ignoreUnreadableDir) return callback();
|
||||
return callback(err);
|
||||
}
|
||||
callback.pending -= 1;
|
||||
files.forEach(function (f, index) {
|
||||
f = path.join(dir, f);
|
||||
callback.pending += 1;
|
||||
fs.stat(f, function (err, stat) {
|
||||
var enoent = false
|
||||
, done = false;
|
||||
|
||||
if (err) {
|
||||
if (err.code !== 'ENOENT' && (err.code !== 'EPERM' && options.ignoreNotPermitted)) {
|
||||
return callback(err);
|
||||
} else {
|
||||
enoent = true;
|
||||
}
|
||||
}
|
||||
callback.pending -= 1;
|
||||
done = callback.pending === 0;
|
||||
if (!enoent) {
|
||||
if (options.ignoreDotFiles && path.basename(f)[0] === '.') return done && callback(null, callback.files);
|
||||
if (options.filter && !options.filter(f, stat)) return done && callback(null, callback.files);
|
||||
callback.files[f] = stat;
|
||||
if (stat.isDirectory() && !(options.ignoreDirectoryPattern && options.ignoreDirectoryPattern.test(f))) walk(f, options, callback);
|
||||
done = callback.pending === 0;
|
||||
if (done) callback(null, callback.files);
|
||||
}
|
||||
})
|
||||
})
|
||||
if (callback.pending === 0) callback(null, callback.files);
|
||||
})
|
||||
if (callback.pending === 0) callback(null, callback.files);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
var watchedFiles = Object.create(null);
|
||||
|
||||
exports.watchTree = function ( root, options, callback ) {
|
||||
if (!callback) {callback = options; options = {}}
|
||||
walk(root, options, function (err, files) {
|
||||
if (err) throw err;
|
||||
var fileWatcher = function (f) {
|
||||
var fsOptions = {};
|
||||
if (options.interval) {
|
||||
fsOptions.interval = options.interval * 1000;
|
||||
}
|
||||
fs.watchFile(f, fsOptions, function (c, p) {
|
||||
// Check if anything actually changed in stat
|
||||
if (files[f] && !files[f].isDirectory() && c.nlink !== 0 && files[f].mtime.getTime() == c.mtime.getTime()) return;
|
||||
files[f] = c;
|
||||
if (!files[f].isDirectory()) callback(f, c, p);
|
||||
else {
|
||||
fs.readdir(f, function (err, nfiles) {
|
||||
if (err) return;
|
||||
nfiles.forEach(function (b) {
|
||||
var file = path.join(f, b);
|
||||
if (!files[file] && (options.ignoreDotFiles !== true || b[0] != '.')) {
|
||||
fs.stat(file, function (err, stat) {
|
||||
if (options.filter && !options.filter(file, stat)) return;
|
||||
callback(file, stat, null);
|
||||
files[file] = stat;
|
||||
fileWatcher(file);
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
if (c.nlink === 0) {
|
||||
// unwatch removed files.
|
||||
delete files[f]
|
||||
fs.unwatchFile(f);
|
||||
}
|
||||
})
|
||||
}
|
||||
fileWatcher(root);
|
||||
for (var i in files) {
|
||||
fileWatcher(i);
|
||||
}
|
||||
watchedFiles[root] = files;
|
||||
callback(files, null, null);
|
||||
})
|
||||
}
|
||||
|
||||
exports.unwatchTree = function (root) {
|
||||
if (!watchedFiles[root]) return;
|
||||
Object.keys(watchedFiles[root]).forEach(fs.unwatchFile);
|
||||
watchedFiles[root] = false;
|
||||
};
|
||||
|
||||
exports.createMonitor = function (root, options, cb) {
|
||||
if (!cb) {cb = options; options = {}}
|
||||
var monitor = new events.EventEmitter();
|
||||
monitor.stop = exports.unwatchTree.bind(null, root);
|
||||
|
||||
var prevFile = {file: null,action: null,stat: null};
|
||||
exports.watchTree(root, options, function (f, curr, prev) {
|
||||
// if not curr, prev, but f is an object
|
||||
if (typeof f == "object" && prev == null && curr === null) {
|
||||
monitor.files = f;
|
||||
return cb(monitor);
|
||||
}
|
||||
|
||||
// if not prev and either prevFile.file is not f or prevFile.action is not created
|
||||
if (!prev) {
|
||||
if (prevFile.file != f || prevFile.action != "created") {
|
||||
prevFile = { file: f, action: "created", stat: curr };
|
||||
return monitor.emit("created", f, curr);
|
||||
}
|
||||
}
|
||||
|
||||
// if curr.nlink is 0 and either prevFile.file is not f or prevFile.action is not removed
|
||||
if (curr) {
|
||||
if (curr.nlink === 0) {
|
||||
if (prevFile.file != f || prevFile.action != "removed") {
|
||||
prevFile = { file: f, action: "removed", stat: curr };
|
||||
return monitor.emit("removed", f, curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if prevFile.file is null or prevFile.stat.mtime is not the same as curr.mtime
|
||||
if (prevFile.file === null) {
|
||||
return monitor.emit("changed", f, curr, prev);
|
||||
}
|
||||
// stat might return null, so catch errors
|
||||
try {
|
||||
if (prevFile.stat.mtime.getTime() !== curr.mtime.getTime()) {
|
||||
return monitor.emit("changed", f, curr, prev);
|
||||
}
|
||||
} catch(e) {
|
||||
return monitor.emit("changed", f, curr, prev);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
exports.walk = walk;
|
73
node_modules/@cnakazawa/watch/package.json
generated
vendored
Normal file
73
node_modules/@cnakazawa/watch/package.json
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"@cnakazawa/watch@1.0.3",
|
||||
"/Users/eric/repos/actions/setup-node"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "@cnakazawa/watch@1.0.3",
|
||||
"_id": "@cnakazawa/watch@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-r5160ogAvGyHsal38Kux7YYtodEKOj89RGb28ht1jh3SJb08VwRwAKKJL0bGb04Zd/3r9FL3BFIc3bBidYffCA==",
|
||||
"_location": "/@cnakazawa/watch",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@cnakazawa/watch@1.0.3",
|
||||
"name": "@cnakazawa/watch",
|
||||
"escapedName": "@cnakazawa%2fwatch",
|
||||
"scope": "@cnakazawa",
|
||||
"rawSpec": "1.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/sane"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.3.tgz",
|
||||
"_spec": "1.0.3",
|
||||
"_where": "/Users/eric/repos/actions/setup-node",
|
||||
"author": {
|
||||
"name": "Mikeal Rogers",
|
||||
"email": "mikeal.rogers@gmail.com"
|
||||
},
|
||||
"bin": {
|
||||
"watch": "./cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mikeal/watch/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"exec-sh": "^0.3.2",
|
||||
"minimist": "^1.2.0"
|
||||
},
|
||||
"description": "Utilities for watching file trees.",
|
||||
"directories": {
|
||||
"lib": "lib"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.1.95"
|
||||
},
|
||||
"homepage": "https://github.com/mikeal/watch",
|
||||
"keywords": [
|
||||
"util",
|
||||
"utility",
|
||||
"fs",
|
||||
"files"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"main": "./main",
|
||||
"name": "@cnakazawa/watch",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mikeal/watch.git"
|
||||
},
|
||||
"scripts": {
|
||||
"release:major": "bash scripts/release.sh major",
|
||||
"release:minor": "bash scripts/release.sh minor",
|
||||
"release:patch": "bash scripts/release.sh patch"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
90
node_modules/@cnakazawa/watch/scripts/release.sh
generated
vendored
Executable file
90
node_modules/@cnakazawa/watch/scripts/release.sh
generated
vendored
Executable file
|
@ -0,0 +1,90 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# ensure git is latest clean branch
|
||||
# require npm user
|
||||
# bump package version
|
||||
# commit
|
||||
# create tag
|
||||
# push commit & tag
|
||||
# publish
|
||||
|
||||
usage() {
|
||||
echo ""
|
||||
echo " Usage: bash $0 <major|minor|patch>"
|
||||
}
|
||||
|
||||
print() {
|
||||
echo "NPM RELEASE: $1"
|
||||
}
|
||||
|
||||
run() {
|
||||
local version=$1
|
||||
|
||||
# ensure git is ready, fetch before making comparisons
|
||||
git fetch
|
||||
local local_sha=$(git rev-parse @)
|
||||
local remote_sha=$(git rev-parse @{u})
|
||||
local base_sha=$(git merge-base @ @{u})
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
print "Commit or stash you changes before releasing"
|
||||
exit 1
|
||||
else
|
||||
print "Working directory is clean"
|
||||
fi
|
||||
|
||||
if [ $local_sha = $remote_sha ]; then
|
||||
print "Local branch is up-to-date."
|
||||
elif [ $local_sha = $base_sha ]; then
|
||||
print "You need to pull changes before you can release."
|
||||
exit 1
|
||||
elif [ $remote_sha = $base_sha ]; then
|
||||
print "You need to push changes before you can release."
|
||||
exit 1
|
||||
else
|
||||
print "Your branch has diverged from the remote, you cannot release."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ensure npm is ready
|
||||
local npm_user=$(npm whoami)
|
||||
local is_collaborator=$(npm access ls-collaborators | grep ".*$npm_user.*:.*write.*")
|
||||
local is_owner=$(npm owner ls | grep ".*$npm_user <.*")
|
||||
|
||||
if ! [[ "$npm_user" ]]; then
|
||||
print "You must be logged in to NPM to publish, run \"npm login\" first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$is_collaborator" ]] && [[ -z "$is_owner" ]]; then
|
||||
print "$npm_user is not an NPM owner or collaborator. Request access from:"
|
||||
npm owner ls
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# all checks out, publish
|
||||
print "Publishing new $version version as $npm_user."
|
||||
|
||||
print "...npm version $version"
|
||||
npm version ${version}
|
||||
|
||||
print "...git push"
|
||||
git push
|
||||
|
||||
print "...git push --follow-tags"
|
||||
git push --follow-tags
|
||||
|
||||
print "...npm publish"
|
||||
npm publish
|
||||
}
|
||||
|
||||
case $1 in
|
||||
"major" | "minor" | "patch")
|
||||
run $1
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
0
node_modules/@cnakazawa/watch/test/d/d/t
generated
vendored
Normal file
0
node_modules/@cnakazawa/watch/test/d/d/t
generated
vendored
Normal file
0
node_modules/@cnakazawa/watch/test/d/t
generated
vendored
Normal file
0
node_modules/@cnakazawa/watch/test/d/t
generated
vendored
Normal file
31
node_modules/@cnakazawa/watch/test/test_monitor.js
generated
vendored
Normal file
31
node_modules/@cnakazawa/watch/test/test_monitor.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
var watch = require('../main')
|
||||
, assert = require('assert')
|
||||
, path = require('path')
|
||||
, fs = require('fs')
|
||||
, target = path.join(__dirname, "d/t")
|
||||
;
|
||||
|
||||
function clearFile() {
|
||||
fs.writeFileSync(target, '')
|
||||
}
|
||||
|
||||
clearFile()
|
||||
|
||||
// test if changed event is fired correctly
|
||||
watch.createMonitor(__dirname, { interval: 150 },
|
||||
function (monitor) {
|
||||
monitor.once('changed', function (f) {
|
||||
assert.equal(f, target);
|
||||
clearFile();
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
fs.writeFile(target, 'Test Write\n', function (err) {
|
||||
if (err) throw err;
|
||||
|
||||
setTimeout(function () {
|
||||
// should have got the other assert done by now
|
||||
assert.ok(false);
|
||||
}, 300);
|
||||
})
|
||||
});
|
28
node_modules/@cnakazawa/watch/test/test_monitorRootDirectory.js
generated
vendored
Normal file
28
node_modules/@cnakazawa/watch/test/test_monitorRootDirectory.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
var fs, watch, watch_original;
|
||||
watch = require('../main');
|
||||
watch_original = require('watch');
|
||||
fs = require('fs');
|
||||
|
||||
watch.createMonitor(__dirname, function (monitor) {
|
||||
monitor.on("created", function (f, stat) {
|
||||
console.log(f + " created");
|
||||
});
|
||||
monitor.on("changed", function (f, curr, prev) {
|
||||
console.log(f + " changed");
|
||||
});
|
||||
monitor.on("removed", function (f, stat) {
|
||||
console.log(f + " removed");
|
||||
});
|
||||
});
|
||||
|
||||
watch_original.createMonitor(__dirname, function (monitor) {
|
||||
monitor.on("created", function (f, stat) {
|
||||
console.log("ORIGINAL: " + f + " created");
|
||||
});
|
||||
monitor.on("changed", function (f, curr, prev) {
|
||||
console.log("ORIGINAL: " + f + " changed");
|
||||
});
|
||||
monitor.on("removed", function (f, stat) {
|
||||
console.log("ORIGINAL: " + f + " removed");
|
||||
});
|
||||
});
|
23
node_modules/@cnakazawa/watch/test/test_watchTree.js
generated
vendored
Normal file
23
node_modules/@cnakazawa/watch/test/test_watchTree.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
var fs = require('fs')
|
||||
, watch = require('../main')
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
//
|
||||
// Demonstrate that the function of 'filter' is semantically inconsistent with
|
||||
// usual convention, that returning true means 'keep this'.
|
||||
//
|
||||
function isDirOrQ(f, stat) { return stat.isDirectory() || f === 'Q'; }
|
||||
|
||||
watch.watchTree(__dirname, { filter: isDirOrQ }, function (f, curr, prev) {
|
||||
if (typeof f == 'object' && prev === null && curr === null) {
|
||||
Object.keys(f).forEach(function(name) {
|
||||
var stat = f[name];
|
||||
assert(isDirOrQ(name, stat));
|
||||
});
|
||||
|
||||
// If the process never exits then `unwatchTree` failed to unwatch all
|
||||
// the files.
|
||||
watch.unwatchTree(__dirname);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue