Skip to content
Merged
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: 1 addition & 1 deletion lib/controllers/prepare-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class PrepareController extends EventEmitter {
projectData: IProjectData
): Promise<string[]> {
const dependencies = this.$nodeModulesDependenciesBuilder
.getProductionDependencies(projectData.projectDir)
.getProductionDependencies(projectData.projectDir, projectData.ignoredDependencies)
.filter((dep) => dep.nativescript);
const pluginsNativeDirectories = dependencies.map((dep) =>
path.join(
Expand Down
2 changes: 1 addition & 1 deletion lib/definitions/platform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ interface IPrepareNodeModulesData {
}

interface INodeModulesDependenciesBuilder {
getProductionDependencies(projectPath: string): IDependencyData[];
getProductionDependencies(projectPath: string, ignore?: string[]): IDependencyData[];
}

interface IBuildInfo {
Expand Down
1 change: 1 addition & 0 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ interface IProjectData extends ICreateProjectData {
projectId: string;
projectIdentifiers?: Mobile.IProjectIdentifier;
dependencies: any;
ignoredDependencies?: string[];
devDependencies: IStringDictionary;
appDirectoryPath: string;
appResourcesDirectoryPath: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/services/plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export class PluginsService implements IPluginsService {
dependencies =
dependencies ||
this.$nodeModulesDependenciesBuilder.getProductionDependencies(
projectData.projectDir
projectData.projectDir, projectData.ignoredDependencies
);

if (_.isEmpty(dependencies)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/project-changes-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class ProjectChangesService implements IProjectChangesService {
);

this.$nodeModulesDependenciesBuilder
.getProductionDependencies(projectData.projectDir)
.getProductionDependencies(projectData.projectDir, projectData.ignoredDependencies)
.filter(
(dep) =>
dep.nativescript &&
Expand Down
2 changes: 1 addition & 1 deletion lib/tools/node-modules/node-modules-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class NodeModulesBuilder implements INodeModulesBuilder {
projectData,
}: IPrepareNodeModulesData): Promise<void> {
const dependencies = this.$nodeModulesDependenciesBuilder.getProductionDependencies(
projectData.projectDir
projectData.projectDir, projectData.ignoredDependencies
);
await platformData.platformProjectService.beforePrepareAllPlugins(
projectData,
Expand Down
6 changes: 4 additions & 2 deletions lib/tools/node-modules/node-modules-dependencies-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class NodeModulesDependenciesBuilder
implements INodeModulesDependenciesBuilder {
public constructor(private $fs: IFileSystem) {}

public getProductionDependencies(projectPath: string): IDependencyData[] {
public getProductionDependencies(projectPath: string, ignore?:string[]): IDependencyData[] {
const rootNodeModulesPath = path.join(
projectPath,
NODE_MODULES_FOLDER_NAME
Expand Down Expand Up @@ -83,7 +83,9 @@ export class NodeModulesDependenciesBuilder
resolvedDependencies.push(resolvedDependency);
}
}

if (ignore && ignore.length > 0) {
return resolvedDependencies.filter(d => ignore.indexOf(d.name) === -1);
}
return resolvedDependencies;
}

Expand Down
40 changes: 40 additions & 0 deletions test/tools/node-modules/node-modules-dependencies-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,46 @@ describe("nodeModulesDependenciesBuilder", () => {

assert.deepStrictEqual(actualResult, expectedResult);
});

it("ignoring dependencies", async () => {
// The test validates the following dependency tree, when npm 3+ is used.
// <project dir>
// ├── [email protected]
// ├── [email protected]
// └── [email protected]

const rootDeps: IDependencyInfo[] = [
generateDependency(firstPackage, "1.0.0", 0, null),
generateDependency(secondPackage, "1.1.0", 0, null),
generateDependency(thirdPackage, "1.2.0", 0, null),
];

const nodeModulesDependenciesBuilder = generateTest(rootDeps);
const actualResult = await nodeModulesDependenciesBuilder.getProductionDependencies(
pathToProject, [firstPackage]
);

const expectedResult: IDependencyData[] = [
getNodeModuleInfoForExpecteDependency(
secondPackage,
0,
null,
null,
null,
"1.1.0"
),
getNodeModuleInfoForExpecteDependency(
thirdPackage,
0,
null,
null,
null,
"1.2.0"
),
];

assert.deepStrictEqual(actualResult, expectedResult);
});
});
});
});