Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions __tests__/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pkg-lib = { version = "0.1.0", path = "./pkg-lib" }
subcrate-d = { workspace = true, path = "../workspace/subcrate_d" }
subcrate-e = { workspace = true, path = "../workspace/subcrate_e" }
subcrate-f = { workspace = true, path = "../workspace/subcrate_f" }
subcrate-g = { workspace = true, path = "../workspace/subcrate_g" }

[dependencies.pkg-bin]
version = "0.1.0"
Expand All @@ -29,3 +30,4 @@ path = "./pkg-bin"
subcrate-d = { version = "0.1.0", path = "./workspace/subcrate_d" }
subcrate-e = { version = "*", path = "./workspace/subcrate_e" }
subcrate-f = { path = "./workspace/subcrate_f" }
subcrate-g = { path = "./workspace/subcrate_g" }
9 changes: 5 additions & 4 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const pkg_dir = __dirname
test('find packages', async () => {
const packages = await findPackages(pkg_dir)

expect(Object.keys(packages).length).toBe(9)
expect(Object.keys(packages).length).toBe(10)

const pkg_all = packages['pkg-all']
const pkg_sys = packages['pkg-sys']
Expand All @@ -18,7 +18,7 @@ test('find packages', async () => {

expect(pkg_all.path).toBe(pkg_dir)
expect(pkg_all.version).toBe('0.1.0')
expect(Object.keys(pkg_all.dependencies).length).toBe(5)
expect(Object.keys(pkg_all.dependencies).length).toBe(6)

expect(pkg_sys.path).toBe(join(pkg_dir, 'pkg-sys'))
expect(pkg_sys.version).toBe('0.1.0')
Expand All @@ -34,7 +34,7 @@ test('find packages', async () => {

expect(subcrate_e.path).toBe(join(pkg_dir, 'workspace/subcrate_e'))
expect(subcrate_e.version).toBe('0.1.0')
expect(Object.keys(subcrate_e.dependencies).length).toBe(2)
expect(Object.keys(subcrate_e.dependencies).length).toBe(3)
})

test('check packages', async () => {
Expand All @@ -53,8 +53,9 @@ test('sort packages', async () => {
'pkg-bin',
'subcrate-d',
'subcrate-f',
'subcrate-e',
'subcrate-g',
'pkg-dev',
'subcrate-e',
'pkg-all'
])
})
Expand Down
4 changes: 4 additions & 0 deletions __tests__/workspace/subcrate_e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ version = "0.1.0"
[dependencies.subcrate-d]
workspace = true

[dependencies.subcrate-g]
path = "../subcrate_g"
package = "thee"

[dev-dependencies.subcrate-f]
path = "../subcrate_f"
1 change: 1 addition & 0 deletions __tests__/workspace/subcrate_e/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub use fuel_dummy_test_subcrate_d::TEST_VALUE as OTHER_TEST_VALUE;
pub use thee::TEST_VALUE as ANOTHER_TEST_VALUE;

#[cfg(test)]
mod tests {
Expand Down
9 changes: 9 additions & 0 deletions __tests__/workspace/subcrate_g/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "subcrate-g"
version.workspace = true

[dependencies]
lazy_static = "1.0"

[dev-dependencies]
lazy_static = "1.0"
10 changes: 10 additions & 0 deletions __tests__/workspace/subcrate_g/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pub const TEST_VALUE: u8 = 5u8;

#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}
9 changes: 6 additions & 3 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface RawDependencies {
kind: RawDependencyKind
req: string
path?: string
rename?: string
}

interface Metadata {
Expand Down Expand Up @@ -41,6 +42,7 @@ export interface Dependency {
kind: DependencyKind
req: string
path?: string
rename?: string
}

export interface Dependencies {
Expand Down Expand Up @@ -131,7 +133,8 @@ export async function findPackages(
dirname(package_info.manifest_path),
dependency.path
)
: undefined
: undefined,
rename: dependency.rename,
}
}

Expand Down Expand Up @@ -227,7 +230,7 @@ export async function checkPackages(
}
if (dependency.path) {
// internal dependency
const dependency_package = packages[dependency_name]
const dependency_package = dependency.rename ? packages[dependency.rename] : packages[dependency_name]
if (!dependency_package) {
errors.push({
name: package_name,
Expand Down Expand Up @@ -304,7 +307,7 @@ export function sortPackages(packages: Packages): string[] {
.filter(
([dependency_name, dependency]) =>
!!dependency.path &&
!sorted_names.includes(dependency_name) &&
(!sorted_names.includes(dependency_name) && (!dependency.rename || !sorted_names.includes(dependency.rename))) &&
dependency.kind !== 'dev'
)
.map(([dependency_name]) => dependency_name)
Expand Down
Loading