Use symlink instead of npm link to install development plugin

This commit is contained in:
Aurelsicoko 2017-09-29 14:56:29 +02:00
parent 85bf446979
commit 76290f2034
2 changed files with 10 additions and 20 deletions

View File

@ -20,7 +20,7 @@ const logger = {
console.log(` console.log(`
Strapi plugin succesfully started in development mode. ${chalk.green('✓')} Strapi plugin succesfully started in development mode. ${chalk.green('✓')}
${divider} ${divider}
${chalk.bold('Access URL:')} ${chalk.magenta(`http://localhost:${port}`)}${divider} ${chalk.bold('Access URL:')} ${chalk.magenta(`http://localhost:${port}${process.env.IS_ADMIN === 'true' ? '/admin' : '' }`)}${divider}
${chalk.blue(`Press ${chalk.italic('CTRL-C')} to stop`)} ${chalk.blue(`Press ${chalk.italic('CTRL-C')} to stop`)}
`); `);
}, },

View File

@ -9,6 +9,7 @@
// Node.js core. // Node.js core.
const { exec } = require('child_process'); const { exec } = require('child_process');
const fs = require('fs'); const fs = require('fs');
const path = require('path');
// Logger. // Logger.
const { cli, logger } = require('strapi-utils'); const { cli, logger } = require('strapi-utils');
@ -40,26 +41,15 @@ module.exports = function (plugin, cliArguments) {
logger.debug('Installation in progress...'); logger.debug('Installation in progress...');
if (cliArguments.dev) { if (cliArguments.dev) {
// Run `npm link` to create a symlink between the node module try {
// installed globally and the current Strapi application. fs.symlinkSync(path.resolve(__dirname, '..', '..', pluginId), path.resolve(process.cwd(), pluginPath), 'dir');
exec(`npm link ${pluginId}`, (err) => {
if (err) {
logger.error('It looks like this plugin is not installed globally.');
process.exit(1);
}
try { logger.info('The plugin has been successfully installed.');
// Create a symlink between the Strapi application and the node module installed. process.exit(0);
fs.symlinkSync(`../node_modules/${pluginId}`, pluginPath, 'dir'); } catch (e) {
logger.error('An error occurred during plugin installation.');
// Success. process.exit(1);
logger.info('The plugin has been successfully installed.'); }
process.exit(0);
} catch (err) {
logger.error('An error occurred during plugin installation.');
process.exit(1);
}
});
} else { } else {
// Debug message. // Debug message.
logger.debug('Installing the plugin from npm registry.'); logger.debug('Installing the plugin from npm registry.');