Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pin 'tslib' to avoid issues when interacting with plugin-plugins #88

Merged
merged 1 commit into from
May 19, 2020
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"inquirer": "^7.1.0",
"qs": "^6.9.3",
"semver": "^7.3.0",
"tslib": "~1.11.2",
"tsv": "^0.2.0",
"twilio": "^3.43.1"
},
Expand Down
8 changes: 4 additions & 4 deletions src/services/require-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ const requireInstall = async (packageName, command) => {
}

// If we're here, attempt to install the package in the plugin's runtime modules path.
try {
logger.warn(`Installing ${packageName} ...`);
const packageTag = targetVersion ? `${packageName}@${targetVersion}` : packageName;
const plugins = new Plugins({ dataDir: pluginPath, cacheDir: pluginPath });
logger.warn(`Installing ${packageName} ...`);
const plugins = new Plugins({ dataDir: pluginPath, cacheDir: pluginPath });

try {
// Init the PJSON in case it doesn't exist. This is required by yarn or it
// moves up the dir tree until it finds one.
await plugins.createPJSON();

// Force install the package in case it's a native module that needs rebuilding.
const packageTag = targetVersion ? `${packageName}@${targetVersion}` : packageName;
await plugins.yarn.exec(['add', '--force', packageTag], { cwd: pluginPath, verbose: false });
} catch (error) {
logger.debug(`Error installing ${packageName}: ${error}`);
Expand Down
14 changes: 13 additions & 1 deletion test/services/require-install.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const tmp = require('tmp');
const { expect, test } = require('@twilio/cli-test');
const { getCommandPlugin, getPackageVersion, getDependencyVersion, checkVersion, requireInstall } = require('../../src/services/require-install');
const { logger, LoggingLevel } = require('../../src/services/messaging/logging');
const corePJSON = require('../../package.json');

const TOP_PLUGIN = {
Expand Down Expand Up @@ -95,13 +96,24 @@ describe('services', () => {
});

describe('requireInstall', () => {
before(() => {
logger.config.level = LoggingLevel.debug;
});

after(() => {
logger.config.level = LoggingLevel.info;
});

test.it('can load existing packages', () => {
expect(requireInstall('chai')).to.not.be.undefined;
});

test.it('will attempt to install packages', async () => {
test.stderr().it('will attempt to install packages', async ctx => {
const command = { id: 'top-command', config };
await expect(requireInstall('chai-dai', command)).to.be.rejected;
expect(ctx.stderr).to.contain('Error loading chai-dai');
expect(ctx.stderr).to.contain('Installing chai-dai');
expect(ctx.stderr).to.contain('Error installing chai-dai');
});
});
});
Expand Down