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

index-tasukaru

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

index-tasukaru - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

24

lib/index.js

@@ -20,3 +20,2 @@ "use strict";

// TODO: support -r for recursive
// TODO: support other than default export
// TODO: support multiple paths

@@ -32,5 +31,6 @@ // TODO: support custom output

boolean: ['f', 'version'],
string: ['sourceExts'],
string: ['sourceExts', 'exportType'],
default: {
sourceExts: 'js,ts',
exportType: 'star',
},

@@ -42,3 +42,8 @@ });

let targetDir = (_a = argv._[0]) !== null && _a !== void 0 ? _a : '.';
let matchedFiles = yield writeIndexForDir(targetDir, splitSourceExtsArg(String(argv.sourceExts).trim()), Boolean(argv.f));
let matchedFiles = yield writeIndexForDir({
targetDir,
sourceExts: splitSourceExtsArg(String(argv.sourceExts).trim()),
force: Boolean(argv.f),
exportType: String(argv.exportType),
});
echo(`Finished exporting ${matchedFiles.length} file(s).`);

@@ -48,4 +53,5 @@ });

exports.main = main;
function writeIndexForDir(targetDir, sourceExts, force) {
function writeIndexForDir(input) {
return __awaiter(this, void 0, void 0, function* () {
let { targetDir, sourceExts, force, exportType } = input;
let workDir = path_1.default.join(process.cwd(), targetDir);

@@ -77,3 +83,6 @@ let files = [];

}
let indexLines = matchedFiles.map(getExportDefaultFromLine);
let useExportStar = exportType === 'star';
let indexLines = matchedFiles.map(useExportStar
? getExportStarLineFromFileName
: getExportDefaultAsFromFileName);
let indexSource = indexLines.join('\n');

@@ -103,5 +112,8 @@ yield fs_extra_1.default.writeFile(targetIndexPath, indexSource + '\n');

}
function getExportDefaultFromLine(fileName) {
function getExportDefaultAsFromFileName(fileName) {
return `export { default as ${getExportName(fileName)} } from '${getModuleName(fileName)}';`;
}
function getExportStarLineFromFileName(fileName) {
return `export * from '${getModuleName(fileName)}';`;
}
function splitSourceExtsArg(sourceExtsArg) {

@@ -108,0 +120,0 @@ return sourceExtsArg.split(',').map((ext) => ext.trim().toLowerCase());

{
"name": "index-tasukaru",
"description": "Generate index file from CLI.",
"version": "0.0.4",
"version": "0.0.5",
"preferGlobal": true,

@@ -6,0 +6,0 @@ "bin": {

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