Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f774fc

Browse files
committed
feat: update version inpackage-lock.json
1 parentda718a3 commit0f774fc

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎lib/update-package-version.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ module.exports = async (version, basePath, logger) => {
1616
logger.log('Wrote version %s to %s',version,shrinkwrapPath);
1717
}
1818

19+
if(awaitpathExists(packageLockPath)){
20+
constpackageLock=awaitreadJson(packageLockPath);
21+
awaitwriteJson(packageLockPath,{...packageLock, ...{version}},{spaces:2});
22+
logger.log('Wrote version %s to %s',version,packageLockPath);
23+
}
1924
};

‎test/update-package-version.test.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ test.serial('Updade package.json and npm-shrinkwrap.json', async t => {
4949
t.deepEqual(t.context.log.args[1],['Wrote version %s to %s','1.0.0','npm-shrinkwrap.json']);
5050
});
5151

52+
test.serial('Updade package.json and package-lock.json',asynct=>{
53+
// Create package.json in repository root
54+
awaitoutputJson('./package.json',{version:'0.0.0-dev'});
55+
// Create a npm-shrinkwrap.json file
56+
awaitexeca('npm',['install']);
57+
58+
awaitupdatePackageVersion('1.0.0','.',t.context.logger);
59+
60+
// Verify package.json and npm-shrinkwrap.json have been updated
61+
t.is((awaitreadJson('./package.json')).version,'1.0.0');
62+
t.is((awaitreadJson('./package-lock.json')).version,'1.0.0');
63+
// Verify the logger has been called with the version updated
64+
t.deepEqual(t.context.log.args[0],['Wrote version %s to %s','1.0.0','package.json']);
65+
t.deepEqual(t.context.log.args[1],['Wrote version %s to %s','1.0.0','package-lock.json']);
66+
});
5267

5368
test.serial('Updade package.json and npm-shrinkwrap.json in a sub-directory',asynct=>{
5469
// Create package.json in repository root

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp