File tree 4 files changed +15
-9
lines changed
4 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -23,4 +23,8 @@ pub enum Subcommands {
23
23
pub struct AddArgs {
24
24
/// Name of the package
25
25
pub package : String ,
26
+ /// The directory with links to the store (default is node_modules/.pacquet).
27
+ /// All direct and indirect dependencies of the project are linked into this directory
28
+ #[ arg( long = "virtual-store-dir" , default_value = "node_modules/.pacquet" ) ]
29
+ pub virtual_store_dir : String ,
26
30
}
Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ pub async fn run_commands() -> Result<()> {
18
18
PackageJson :: create ( ) ?;
19
19
}
20
20
Subcommands :: Add ( args) => {
21
- let mut registry_manager = RegistryManager :: new ( current_directory. join ( "node_modules" ) ) ;
21
+ let mut registry_manager = RegistryManager :: new (
22
+ current_directory. join ( "node_modules" ) ,
23
+ current_directory. join ( & args. virtual_store_dir ) ,
24
+ ) ;
22
25
registry_manager. prepare ( ) ?;
23
26
registry_manager. add_dependency ( & args. package ) . await ?;
24
27
}
Original file line number Diff line number Diff line change @@ -23,12 +23,11 @@ pub struct RegistryManager {
23
23
}
24
24
25
25
impl RegistryManager {
26
- pub fn new < P : Into < PathBuf > > ( path : P ) -> RegistryManager {
27
- let path_into = path. into ( ) ;
26
+ pub fn new < P : Into < PathBuf > > ( node_modules_path : P , store_path : P ) -> RegistryManager {
28
27
RegistryManager {
29
28
client : Client :: new ( ) ,
30
- node_modules_path : path_into . clone ( ) ,
31
- store_path : path_into . join ( ".pacquet" ) ,
29
+ node_modules_path : node_modules_path . into ( ) ,
30
+ store_path : store_path . into ( ) ,
32
31
}
33
32
}
34
33
@@ -49,6 +48,7 @@ impl RegistryManager {
49
48
& latest_version. version ,
50
49
latest_version. get_tarball_url ( ) ,
51
50
& self . node_modules_path ,
51
+ & self . store_path ,
52
52
& id,
53
53
)
54
54
. await ?;
@@ -90,7 +90,7 @@ impl RegistryManager {
90
90
& package. name ,
91
91
& package_version. version ,
92
92
package_version. get_tarball_url ( ) ,
93
- & self . node_modules_path ,
93
+ & self . store_path ,
94
94
& symlink_path. join ( & package. name ) ,
95
95
)
96
96
. await ?;
Original file line number Diff line number Diff line change @@ -50,13 +50,13 @@ pub async fn download_direct_dependency(
50
50
version : & str ,
51
51
url : & str ,
52
52
node_modules_path : & Path ,
53
+ store_path : & Path ,
53
54
// For example: fastify@1.1.0
54
55
// For dependencies of fastify: fastify@1.1.0/node_modules/fastify
55
56
package_identifier : & str ,
56
57
) -> Result < ( ) , TarballError > {
57
58
let store_folder_name = format ! ( "{0}@{version}" , normalize( name) ) ;
58
59
59
- let store_path = node_modules_path. join ( ".pacquet" ) ;
60
60
let tarball_path = store_path. join ( format ! ( "{store_folder_name}.tar.gz" ) ) ;
61
61
let package_path =
62
62
store_path. join ( normalize ( package_identifier) ) . join ( "node_modules" ) . join ( name) ;
@@ -90,12 +90,11 @@ pub async fn download_indirect_dependency(
90
90
name : & str ,
91
91
version : & str ,
92
92
url : & str ,
93
- node_modules_path : & Path ,
93
+ store_path : & Path ,
94
94
symlink_to : & Path ,
95
95
) -> Result < ( ) , TarballError > {
96
96
let store_folder_name = format ! ( "{0}@{version}" , normalize( name) ) ;
97
97
98
- let store_path = node_modules_path. join ( ".pacquet" ) ;
99
98
let tarball_path = store_path. join ( format ! ( "{store_folder_name}.tar.gz" ) ) ;
100
99
let package_path = store_path. join ( & store_folder_name) . join ( "node_modules" ) . join ( name) ;
101
100
You can’t perform that action at this time.
0 commit comments