mirror of
https://github.com/strapi/strapi.git
synced 2025-12-05 11:32:13 +00:00
Use symlink instead of npm link to install development plugin
This commit is contained in:
parent
85bf446979
commit
76290f2034
@ -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`)}
|
||||
`);
|
||||
},
|
||||
|
||||
@ -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.');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user