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(`
Strapi plugin succesfully started in development mode. ${chalk.green('✓')}
${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`)}
`);
},

View File

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