Skip to content

Commit

Permalink
fix: rest deploy without fs :D
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Mar 30, 2021
1 parent 8e7c59e commit 9a4202d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
14 changes: 2 additions & 12 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as os from 'os';
import { URL } from 'url';
import { AsyncResult, DeployOptions, DeployResultLocator } from 'jsforce/api/metadata';
import { Callback } from 'jsforce/connection';
Expand Down Expand Up @@ -33,7 +32,6 @@ import {
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
import * as Transport from 'jsforce/lib/transport';
import { fs } from './util/fs';
import { AuthFields, AuthInfo } from './authInfo';
import { MyDomainResolver } from './status/myDomainResolver';
import { ConfigAggregator } from './config/configAggregator';
Expand Down Expand Up @@ -169,13 +167,6 @@ export class Connection extends JSForceConnection {
return conn;
}

private static createReadStreamFromBuffer(buffer: Buffer) {
const zip = 'metadata.zip';
fs.writeFileSync(os.tmpdir() + zip, buffer);
const f = fs.createReadStream(os.tmpdir() + zip);
fs.unlinkSync(os.tmpdir() + zip);
return f;
}
/**
* Async initializer.
*/
Expand Down Expand Up @@ -214,11 +205,10 @@ export class Connection extends JSForceConnection {
});
const form = req.form();

const stream = Connection.createReadStreamFromBuffer(zipInput);

// Add the zip file
form.append('file', stream, {
form.append('file', zipInput, {
contentType: 'application/zip',
filename: 'package.xml',
});

// Add the deploy options
Expand Down
14 changes: 0 additions & 14 deletions test/unit/connectionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Duration } from '@salesforce/kit';
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
import * as Transport from 'jsforce/lib/transport';
import { fs } from '../../src/util/fs';
import { AuthInfo } from '../../src/authInfo';
import { MyDomainResolver } from '../../src/status/myDomainResolver';
import { ConfigAggregator, ConfigInfo } from '../../src/config/configAggregator';
Expand Down Expand Up @@ -227,19 +226,6 @@ describe('Connection', () => {
await conn.deploy(new Buffer('test data'), { rest: false }, () => {});
expect(soapDeployStub.callCount).to.equal(1);
});

it('createReadStreamFromBuffer will be called correctly', () => {
const writeStub = $$.SANDBOX.stub(fs, 'writeFileSync');
const readStreamStub = $$.SANDBOX.stub(fs, 'createReadStream');
const unlinkStub = $$.SANDBOX.stub(fs, 'unlinkSync');
// private method
// @ts-ignore
Connection.createReadStreamFromBuffer(new Buffer('test data'));

expect(writeStub.callCount).to.equal(1);
expect(readStreamStub.callCount).to.equal(1);
expect(unlinkStub.callCount).to.equal(1);
});
});

it('autoFetchQuery() should call this.query with proper args', async () => {
Expand Down

0 comments on commit 9a4202d

Please sign in to comment.