fix(angular): support large buffers in angular cli adapter (#15082)
This commit is contained in:
parent
861bad90d8
commit
a1a1cdaf4a
11
packages/nx/src/adapter/ngcli-adapter.spec.ts
Normal file
11
packages/nx/src/adapter/ngcli-adapter.spec.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { arrayBufferToString } from './ngcli-adapter';
|
||||||
|
|
||||||
|
describe('ngcli-adapter', () => {
|
||||||
|
it('arrayBufferToString should support large buffers', () => {
|
||||||
|
const largeString = 'a'.repeat(1000000);
|
||||||
|
|
||||||
|
const result = arrayBufferToString(Buffer.from(largeString));
|
||||||
|
|
||||||
|
expect(result).toBe(largeString);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -388,8 +388,19 @@ export class NxScopedHost extends virtualFs.ScopedHost<any> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function arrayBufferToString(buffer: any) {
|
export function arrayBufferToString(buffer: any) {
|
||||||
return String.fromCharCode.apply(null, new Uint8Array(buffer));
|
const array = new Uint8Array(buffer);
|
||||||
|
let result = '';
|
||||||
|
const chunkSize = 8 * 1024;
|
||||||
|
let i = 0;
|
||||||
|
for (i = 0; i < array.length / chunkSize; i++) {
|
||||||
|
result += String.fromCharCode.apply(
|
||||||
|
null,
|
||||||
|
array.subarray(i * chunkSize, (i + 1) * chunkSize)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
result += String.fromCharCode.apply(null, array.subarray(i * chunkSize));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NxScopeHostUsedForWrappedSchematics extends NxScopedHost {
|
export class NxScopeHostUsedForWrappedSchematics extends NxScopedHost {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user