Skip to content

Commit f3398b0

Browse files
committed
Enhance develop --with-dependencies
Make `develop --with-dependencies` to skip already existing directories when cloning the repositories. This is useful when a second `develop --with-dependencies` is executed for another package and some of the dependencies are the same as in the first run. In that case, we don't want the entire command to fail because some package directories already exist. Related to #127
1 parent c47c5c4 commit f3398b0

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/nimble.nim

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,19 @@ proc downloadDependency(name: string, dep: LockFileDep, options: Options):
537537
getDevelopDownloadDir(url, subdir, options) else: ""
538538

539539
if dirExists(downloadPath):
540-
raiseCannotCloneInExistingDirException(downloadPath)
540+
if options.developWithDependencies:
541+
displayWarning(skipDownloadingInAlreadyExistingDirectoryMsg(
542+
downloadPath, name))
543+
result = DownloadInfo(
544+
name: name,
545+
dependency: dep,
546+
url: url,
547+
version: version,
548+
downloadDir: downloadPath,
549+
vcsRevision: dep.vcsRevision.newClone)
550+
return
551+
else:
552+
raiseCannotCloneInExistingDirException(downloadPath)
541553

542554
let (downloadDir, _, vcsRevision) = await downloadPkg(
543555
url, version, dep.downloadMethod, subdir, options, downloadPath,
@@ -1213,7 +1225,16 @@ proc installDevelopPackage(pkgTup: PkgTuple, options: var Options):
12131225
let downloadDir = getDevelopDownloadDir(url, subdir, options)
12141226

12151227
if dirExists(downloadDir):
1216-
raiseCannotCloneInExistingDirException(downloadDir)
1228+
if options.developWithDependencies:
1229+
displayWarning(skipDownloadingInAlreadyExistingDirectoryMsg(
1230+
downloadDir, pkgTup.name))
1231+
let pkgInfo = getPkgInfo(downloadDir, options)
1232+
developFromDir(pkgInfo, options)
1233+
options.action.devActions.add(
1234+
(datAdd, pkgInfo.getNimbleFileDir.normalizedPath))
1235+
return pkgInfo
1236+
else:
1237+
raiseCannotCloneInExistingDirException(downloadDir)
12171238

12181239
# Download the HEAD and make sure the full history is downloaded.
12191240
let ver =

src/nimblepkg/displaymessages.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,7 @@ proc pkgAlreadyExistsInTheCacheMsg*(pkgInfo: PackageInfo): string =
153153
pkgInfo.basicInfo.name,
154154
$pkgInfo.basicInfo.version,
155155
$pkgInfo.basicInfo.checksum)
156+
157+
proc skipDownloadingInAlreadyExistingDirectoryMsg*(dir, name: string): string =
158+
&"The download directory \"{dir}\" already exists.\n" &
159+
&"Skipping the download of \"{name}\"."

0 commit comments

Comments
 (0)