Skip to content

Commit

Permalink
make keepUpArrow more useful as keepPrefix
Browse files Browse the repository at this point in the history
  • Loading branch information
pietvanzoen committed Nov 29, 2018
1 parent 3b668bb commit 9cf831f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.ts
Expand Up @@ -13,7 +13,7 @@ program
.option('-d, --dir <path>', 'directory path where the yarn.lock file is located (default to current directory)')
.option('-p, --dirPackageJson <path>', 'directory of project with target package.json, if not set, -d will be used')
.option('-s, --save', 'By default don\'t override the package.json file, make a new one instead package.json.yarn ')
.option('-k, --keepUpArrow', 'By default the ^ or any other dynamic numbers are removed and replaced with static ones.')
.option('-k, --keepPrefix', 'By default the ^ or any other dynamic numbers are removed and replaced with static ones.')
.option('-g, --keepGit', 'By default direct git repositories are also replaced by the version written in yarn.')
.option('-l, --keepLink', 'By default direct link: repositories are also replaced by the version written in yarn.')
.option('-a, --keepVariable <variable>', 'By default everything is converted to yarn version, write a part of the type you wish not to convert, seperate by comma if more than one, to not replace git and link you would use +,link:')
Expand All @@ -27,7 +27,12 @@ const proccessVersion = (newVersion, currentVersion) => {
return currentVersion;
if (program.keepVariable && program.keepVariable.split(',').find(f => currentVersion.includes(f)))
return currentVersion;
return program.keepUpArrow ? `^${newVersion}` : newVersion;
if (program.keepPrefix) {
const match = currentVersion.match(/(^[\^><=]+)/);
const range = match ? match[0] : '';
return range + newVersion;
}
return newVersion;
}


Expand Down

0 comments on commit 9cf831f

Please sign in to comment.