Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

link-module-alias

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

link-module-alias - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

34

index.js

@@ -28,3 +28,2 @@ #!/usr/bin/env node

const writeFile = promisify(fs.writeFile);
const execFile = promisify(child_process.execFile);
const unlink = promisify(fs.unlink);

@@ -40,9 +39,9 @@ const readdir = promisify(fs.readdir);

if(type === 'none') {
moduleName = chalk.red(moduleName);
return chalk.red(moduleName) + ` -> ${chalk.bold(chalk.red('ALREADY EXISTS'))}`;
} else if(type === 'symlink') {
moduleName = chalk.cyan(moduleName);
return chalk.cyan(moduleName) + ` -> ${chalk.bold(target)}`;
} else if(type === 'proxy') {
moduleName = chalk.green(moduleName);
return chalk.green(moduleName) + ` -> ${chalk.bold(target)}`;
}
return `${moduleName} -> ${chalk.bold(target)}`;
return `${moduleName} `;
}

@@ -71,9 +70,8 @@

async function unlinkModule(moduleName) {
const moduleDir = path.join('node_modules', moduleName);
let statKey;
try {
statKey = await lstat(`node_modules/${moduleName}`);
statKey = await lstat(moduleDir);
} catch(err) {}
const moduleDir = path.join('node_modules', moduleName);
let type;

@@ -105,3 +103,4 @@ if(statKey && statKey.isSymbolicLink()) {

async function linkModule(moduleName) {
const moduleExists = await exists(`node_modules/${moduleName}`);
const moduleDir = path.join('node_modules', moduleName);
const moduleExists = await exists(moduleDir);
const linkExists = moduleExists && await exists(`node_modules/.link-module-alias-${moduleName}`);

@@ -112,3 +111,3 @@ const target = moduleAliases[moduleName];

if(moduleExists && !linkExists) {
console.error(`Module ${moduleName} already exists and wasn't created by us, skipping`);
console.error(chalk.red(`Module ${moduleName} already exists and wasn't created by us, skipping`));
type = 'none';

@@ -122,4 +121,4 @@ return { moduleName, type, target };

// console.log(`Target ${target} is a direct link, creating proxy require`);
await mkdir(`node_modules/${moduleName}`);
await writeFile(`node_modules/${moduleName}/package.json`, js`
await mkdir(moduleDir);
await writeFile(path.join(moduleDir, 'package.json'), js`
{

@@ -138,6 +137,6 @@ "name": ${moduleName},

}
await symlink(path.join('../', target), `node_modules/${moduleName}`);
await symlink(path.join('../', target), moduleDir, 'dir');
type = 'symlink';
}
await writeFile(`node_modules/.link-module-alias-${moduleName}`, '');
await writeFile(path.join('node_modules', `.link-module-alias-${moduleName}`), '');
return { moduleName, type, target };

@@ -147,2 +146,3 @@ }

async function linkModules() {
try { await mkdir('node_modules'); } catch(err) {}
const modules = await Promise.all(Object.keys(moduleAliases).map(async key => {

@@ -155,2 +155,6 @@ return linkModule(key);

async function unlinkModules() {
const nodeModulesExists = await exists('node_modules');
if(!nodeModulesExists) {
return;
}
const allModules = await readdir('node_modules');

@@ -168,3 +172,3 @@

console.log('link-module-alias: Cleaned ', unlinkedModules.filter(v => {
return v !== 'none';
return v.type !== 'none';
}).map(addColorUnlink).join(' '));

@@ -171,0 +175,0 @@ } else {

{
"name": "link-module-alias",
"version": "1.1.2",
"version": "1.1.3",
"description": "Create permanent links for _moduleAliases",

@@ -5,0 +5,0 @@ "bin": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc