File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,12 @@ uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
33authors = [
" Tim Holy <[email protected] >" ]
44version = " 0.1.0"
55
6+ [deps ]
7+ UUIDs = " cf7118a7-6976-5b1a-9a39-7adc72f591a4"
8+
69[extras ]
10+ ColorTypes = " 3da002f7-5984-5a60-b8a6-cbb66c0b333f"
711Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
812
913[targets ]
10- test = [" Test" ]
14+ test = [" Test" , " ColorTypes " ]
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ module CodeTracking
22
33using Base: PkgId
44using Core: LineInfoNode
5+ using UUIDs
56
67export PkgFiles
78export whereis, definition, pkgfiles
8182definition (method:: Method ) = definition (method, Expr)
8283
8384"""
84- info = pkgfiles(id::PkgId)
85+ info = pkgfiles(name::AbstractString)
86+ info = pkgfiles(name::AbstractString, uuid::UUID)
8587
86- Return a [`PkgFiles`](@ref) structure with information about the files that define package `id`.
87- Returns `nothing` if `id` has not been loaded.
88+ Return a [`PkgFiles`](@ref) structure with information about the files that define the package
89+ specified by `name` and `uuid`.
90+ Returns `nothing` if this package has not been loaded.
8891"""
92+ pkgfiles (name:: AbstractString , uuid:: UUID ) = pkgfiles (PkgId (uuid, name))
93+ function pkgfiles (name:: AbstractString )
94+ project = Base. active_project ()
95+ uuid = Base. project_deps_get (project, name)
96+ uuid == false && error (" no package " , name, " recognized" )
97+ return pkgfiles (name, uuid)
98+ end
8999pkgfiles (id:: PkgId ) = get (_pkgfiles, id, nothing )
90100
91101"""
Original file line number Diff line number Diff line change 11using CodeTracking
22using Test
3+ # Note: ColorTypes needs to be installed, but note the absence of `using`
34
45include (" script.jl" )
56
@@ -28,4 +29,7 @@ include("script.jl")
2829 show (io, info)
2930 str = String (take! (io))
3031 @test startswith (str, " PkgFiles(CodeTracking [da1fd8a2-8d9e-5ec2-8556-3022fb5608a2]):\n basedir:" )
32+
33+ @test pkgfiles (" ColorTypes" ) === nothing
34+ @test_throws ErrorException pkgfiles (" NotAPkg" )
3135end
You can’t perform that action at this time.
0 commit comments