mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Fix community package installation on windows (#15685)
This commit is contained in:
committed by
GitHub
parent
c2449ee2c8
commit
647cb851e5
@@ -6,7 +6,7 @@ import { InstalledNodesRepository } from '@n8n/db';
|
|||||||
import { InstalledPackagesRepository } from '@n8n/db';
|
import { InstalledPackagesRepository } from '@n8n/db';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { mkdir as fsMkdir, readFile, writeFile } from 'fs/promises';
|
import { mkdir as fsMkdir, readFile, writeFile, rm } from 'fs/promises';
|
||||||
import { mocked } from 'jest-mock';
|
import { mocked } from 'jest-mock';
|
||||||
import { mock } from 'jest-mock-extended';
|
import { mock } from 'jest-mock-extended';
|
||||||
import type { Logger, InstanceSettings, PackageDirectoryLoader } from 'n8n-core';
|
import type { Logger, InstanceSettings, PackageDirectoryLoader } from 'n8n-core';
|
||||||
@@ -446,37 +446,33 @@ describe('CommunityPackagesService', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// ASSERT:
|
// ASSERT:
|
||||||
expect(exec).toHaveBeenCalledTimes(5);
|
expect(exec).toHaveBeenCalledTimes(4);
|
||||||
|
|
||||||
|
expect(rm).toHaveBeenCalledWith(testBlockPackageDir, { recursive: true, force: true });
|
||||||
|
|
||||||
expect(exec).toHaveBeenNthCalledWith(
|
expect(exec).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
`rm -rf ${testBlockPackageDir}`,
|
|
||||||
expect.any(Function),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(exec).toHaveBeenNthCalledWith(
|
|
||||||
2,
|
|
||||||
`npm pack ${PACKAGE_NAME}@latest --registry=${testBlockRegistry} --quiet`,
|
`npm pack ${PACKAGE_NAME}@latest --registry=${testBlockRegistry} --quiet`,
|
||||||
{ cwd: testBlockDownloadDir },
|
{ cwd: testBlockDownloadDir },
|
||||||
expect.any(Function),
|
expect.any(Function),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(exec).toHaveBeenNthCalledWith(
|
expect(exec).toHaveBeenNthCalledWith(
|
||||||
3,
|
2,
|
||||||
`tar -xzf ${testBlockTarballName} -C ${testBlockPackageDir} --strip-components=1`,
|
`tar -xzf ${testBlockTarballName} -C ${testBlockPackageDir} --strip-components=1`,
|
||||||
{ cwd: testBlockDownloadDir },
|
{ cwd: testBlockDownloadDir },
|
||||||
expect.any(Function),
|
expect.any(Function),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(exec).toHaveBeenNthCalledWith(
|
expect(exec).toHaveBeenNthCalledWith(
|
||||||
4,
|
3,
|
||||||
`npm install ${testBlockNpmInstallArgs}`,
|
`npm install ${testBlockNpmInstallArgs}`,
|
||||||
{ cwd: testBlockPackageDir },
|
{ cwd: testBlockPackageDir },
|
||||||
expect.any(Function),
|
expect.any(Function),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(exec).toHaveBeenNthCalledWith(
|
expect(exec).toHaveBeenNthCalledWith(
|
||||||
5,
|
4,
|
||||||
`rm ${testBlockTarballName}`,
|
`rm ${testBlockTarballName}`,
|
||||||
{ cwd: testBlockDownloadDir },
|
{ cwd: testBlockDownloadDir },
|
||||||
expect.any(Function),
|
expect.any(Function),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { InstalledPackagesRepository } from '@n8n/db';
|
|||||||
import { Service } from '@n8n/di';
|
import { Service } from '@n8n/di';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { mkdir, readFile, writeFile } from 'fs/promises';
|
import { mkdir, readFile, writeFile, rm } from 'fs/promises';
|
||||||
import type { PackageDirectoryLoader } from 'n8n-core';
|
import type { PackageDirectoryLoader } from 'n8n-core';
|
||||||
import { InstanceSettings, Logger } from 'n8n-core';
|
import { InstanceSettings, Logger } from 'n8n-core';
|
||||||
import { UnexpectedError, UserError, type PublicInstalledPackage } from 'n8n-workflow';
|
import { UnexpectedError, UserError, type PublicInstalledPackage } from 'n8n-workflow';
|
||||||
@@ -481,6 +481,6 @@ export class CommunityPackagesService {
|
|||||||
|
|
||||||
private async deletePackageDirectory(packageName: string) {
|
private async deletePackageDirectory(packageName: string) {
|
||||||
const packageDirectory = this.resolvePackageDirectory(packageName);
|
const packageDirectory = this.resolvePackageDirectory(packageName);
|
||||||
await asyncExec(`rm -rf ${packageDirectory}`);
|
await rm(packageDirectory, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user