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

Commita457fdc

Browse files
pathurspvdlg
authored andcommitted
fix: skip tarball move if config iscwd
1 parent9498e21 commita457fdc

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

‎lib/prepare.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ module.exports = async ({tarballDir, pkgRoot}, {cwd, env, stdout, stderr, nextRe
3232
);
3333

3434
consttarball=(awaitpackResult).stdout.split('\n').pop();
35-
awaitmove(path.resolve(cwd,tarball),path.resolve(cwd,tarballDir.trim(),tarball));
35+
consttarballSource=path.resolve(cwd,tarball);
36+
consttarballDestination=path.resolve(cwd,tarballDir.trim(),tarball);
37+
38+
// Only move the tarball if we need to
39+
// Fixes: https://github.com/semantic-release/npm/issues/169
40+
if(tarballSource!==tarballDestination){
41+
awaitmove(tarballSource,tarballDestination);
42+
}
3643
}
3744
};

‎test/prepare.test.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,29 @@ test('Create the package in the "tarballDir" directory', async t => {
226226
// Verify the logger has been called with the version updated
227227
t.deepEqual(t.context.log.args[0],['Write version %s to package.json in %s','1.0.0',cwd]);
228228
});
229+
230+
test('Only move the created tarball if the "tarballDir" directory is not the CWD',asynct=>{
231+
constcwd=tempy.directory();
232+
constpackagePath=path.resolve(cwd,'package.json');
233+
constpkg={name:'my-pkg',version:'0.0.0-dev'};
234+
awaitoutputJson(packagePath,pkg);
235+
236+
awaitprepare(
237+
{tarballDir:'.'},
238+
{
239+
cwd,
240+
env:{},
241+
stdout:t.context.stdout,
242+
stderr:t.context.stderr,
243+
nextRelease:{version:'1.0.0'},
244+
logger:t.context.logger,
245+
}
246+
);
247+
248+
// Verify package.json has been updated
249+
t.is((awaitreadJson(packagePath)).version,'1.0.0');
250+
251+
t.true(awaitpathExists(path.resolve(cwd,`${pkg.name}-1.0.0.tgz`)));
252+
// Verify the logger has been called with the version updated
253+
t.deepEqual(t.context.log.args[0],['Write version %s to package.json in %s','1.0.0',cwd]);
254+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp