New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@itrocks/prepare-module

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@itrocks/prepare-module - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

2

package.json

@@ -30,3 +30,3 @@ {

"types": "./prepare-module.d.ts",
"version": "0.0.9"
"version": "0.0.10"
}

@@ -7,33 +7,39 @@ #!/usr/bin/env node

const destDir = '.';
async function getNamespace() {
const name = JSON.parse(await fs_1.promises.readFile('package.json', 'utf8')).name;
return name.startsWith('@')
? name.slice(0, name.indexOf('/'))
: undefined;
}
(async () => {
const namespace = await getNamespace();
const case1 = new RegExp(`import(.*)from\\s+'../node_modules/${namespace}/`, 'g');
const case2 = new RegExp(`import(.*)from\\s+'../node_modules/`, 'g');
const files = await fs_1.promises.readdir(srcDir);
for (const file of files) {
const srcPath = srcDir + '/' + file;
const destPath = destDir + '/' + file;
if (file.endsWith('.js')) {
let content = (await fs_1.promises.readFile(srcPath, 'utf8'));
if (namespace) {
content = content
.replace(case1, "import$1from '../")
.replace(case2, "import$1from '../../");
const case1 = new RegExp(`../node_modules/${namespace}/`, 'g');
const case2 = new RegExp(`../node_modules/`, 'g');
async function getNamespace() {
const name = JSON.parse(await fs_1.promises.readFile('package.json', 'utf8')).name;
return name.startsWith('@')
? name.slice(0, name.indexOf('/'))
: undefined;
}
async function prepareDir(srcDir, destDir) {
for (const file of await fs_1.promises.readdir(srcDir)) {
const srcPath = srcDir + '/' + file;
const destPath = destDir + '/' + file;
if ((file[0] !== '.') && (await fs_1.promises.lstat(srcPath)).isDirectory()) {
try {
await fs_1.promises.access(destPath);
}
catch {
await fs_1.promises.mkdir(destPath);
}
await prepareDir(srcPath, destPath);
continue;
}
else {
content = content
.replace(case2, "import$1from '../");
if (file.endsWith('.js')) {
let content = (await fs_1.promises.readFile(srcPath, 'utf8'));
content = namespace
? content.replace(case1, "../").replace(case2, "../../")
: content.replace(case2, "../");
await fs_1.promises.writeFile(destPath, content, 'utf8');
}
await fs_1.promises.writeFile(destPath, content, 'utf8');
else if (file.endsWith('.d.ts')) {
await fs_1.promises.copyFile(srcPath, destPath);
}
}
else if (file.endsWith('.d.ts')) {
await fs_1.promises.copyFile(srcPath, destPath);
}
}
await prepareDir(srcDir, destDir);
})().catch();
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