Add node modules and new code for release (#39)

Co-authored-by: tbarnes94 <tbarnes94@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2022-01-05 11:26:06 -05:00
committed by GitHub
parent a10d84bc2e
commit 7ad2aa66bb
7655 changed files with 1763577 additions and 14 deletions

63
node_modules/sane/src/watchexec_client.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
/*
This file is the executable run by watchexec
when a change is detected.
It will extract changes from the environment variables
set by watchexec and write to stdout in a format
readable by the file `../watchexec_watcher.js`.
*/
'use strict';
const { EOL } = require('os');
function withPrefixes(prefixes) {
return function withPrefix(arr, i) {
return arr.map(str => {
return `${prefixes[i]} ${str}`;
});
};
}
let allPrefixes = ['write', 'rename', 'remove', 'create'];
function extractChanges(context) {
const {
WATCHEXEC_COMMON_PATH,
WATCHEXEC_WRITTEN_PATH,
WATCHEXEC_RENAMED_PATH,
WATCHEXEC_REMOVED_PATH,
WATCHEXEC_CREATED_PATH,
} = context;
let events = [
WATCHEXEC_WRITTEN_PATH,
WATCHEXEC_RENAMED_PATH,
WATCHEXEC_REMOVED_PATH,
WATCHEXEC_CREATED_PATH,
];
let currentPrefixes = events
.map((l, i) => l && allPrefixes[i])
.filter(Boolean);
function toFullPath(arr) {
return arr.map(path => (WATCHEXEC_COMMON_PATH || '') + path);
}
let message = events
.filter(Boolean)
.map(str => str.split(':'))
.map(toFullPath)
.map(withPrefixes(currentPrefixes))
.reduce((e, memo) => memo.concat(e), [])
.join(EOL);
return message;
}
if (require.main === module) {
let message = extractChanges(process.env);
console.log(message);
}
module.exports = extractChanges;