folder-semver
v0.0.1
Published
Predict semver update type based on changes between 2 folders
Downloads
1
Readme
folder-semver
Compare two folders of assets and get a semver update type based on the differences in the files.
Use this module to keep track of changes in assets that are refered to by file name.
We treat the file names as the "method signatures", so for an asset that is changed but has the same name the change is a patch, whenver we add a file it is a minor and when a file is deleted or moved the change is a major.
How to use
folderSemver(oldFolderPath, newFolderPath, options)
Arguments:
oldFolderPath
stringnewFolderPath
stringoptions
object, can be used to activate verbose mode
The exported function returns:
null
when there is no change in the files"major"
when the old build contains files not present in the new build. The api has changed and things depending of the old file structure might break."minor"
when files are added to the new build. A new feature has been added to the api."patch"
when the filenames are equal but there are other changes to the files. A bug has been fixed but the api is unchanged.
Example
var folderSemver = require('folder-semver')
folderSemver('oldBuild/assets', 'newBuild/assets');
// returns "major", "minor", "patch" or null
Example with verbose mode
Verbose mode will log a diff of the changes in the build to the console.
var folderSemver = require('folder-semver')
folderSemver('oldBuild/assets', 'newBuild/assets');
// + added_file.svg
// - removed_file.svg
// ~ changed_file.svg
// returns "major", "minor", "patch" or null
Tests
See tests.js for the test suite.
To run the test suite use this command.
npm test