chuwanghui 6d115466a5 electron库 | 6 éve | |
---|---|---|
.. | ||
.npminstall.done | 6 éve | |
LICENSE | 6 éve | |
NEWS.md | 6 éve | |
README.md | 6 éve | |
build.js | 6 éve | |
package.json | 6 éve |
Sumchecker is a pure Node.js solution to validating files specified in a checksum file, which are
usually generated by programs such as sha256sum
.
sumchecker(algorithm, checksumFilename, baseDir, filesToCheck)
.then(() => {
console.log('All files validate!');
}, (error) => {
console.error('An error occurred', error);
});
Returns a Promise
. The promise is resolved when all files specified
in filesToCheck
are validated. The promise is rejected otherwise.
algorithm
String
- The hash algorithm used in checksumFilename
. Corresponds to the
algorithms allowed by crypto.createHash()
.
checksumFilename
String
- The path to the checksum file.
baseDir
String
- The base directory for the files specified in filesToCheck
.
filesToCheck
Array
or String
- one or more paths of the files that will be validated, relative to
baseDir
.
These are sumchecker
-specific error classes that are passed to the promise's reject callback.
sumchecker.ChecksumMismatchError
When at least one of the files does not match its expected checksum.
Properties:
filename
(String
) - a path to a file that did not matchsumchecker.ChecksumParseError
When the checksum file cannot be parsed (as in, it does not match the checksum file format).
Properties:
lineNumber
(Number
) - the line number that could not be parsedline
(String
) - the raw line data that could not be parsed, sans newlinesumchecker.NoChecksumFoundError
When at least one of the files specified to check is not listed in the checksum file.
Properties:
filename
(String
)- a filename from filesToCheck
This library is copyrighted under the terms of the Apache 2.0 License.