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

ng-barrel

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-barrel - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

39

ng-barrel.js

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

stdin.on('end', function () {
if(data.trim().length === 0) {
if (data.trim().length === 0) {
headers.NgBarrel();

@@ -47,15 +47,5 @@ log.error("No input received.");

const possiblePlaces = getPossibilities(directory, config.barrel);
const closestBarrel = possiblePlaces.find(path => fs.existsSync(path));
headers.NgBarrel();
if (closestBarrel !== undefined) {
const closestBarrelPath = strings.trimEnd(config.barrel, closestBarrel);
const fromPath = strings.trimStart(closestBarrelPath, directory + moduleName);
const exportStatement = strings.exportStatement(fromPath);
fs.appendFileSync(closestBarrel, `${exportStatement}\n`);
log.fileWriteEvent(exportStatement, closestBarrel);
} else if (config.create !== undefined) {
if (config.create !== undefined) {
const p = path.join(directory, config.create);

@@ -67,6 +57,25 @@ const newFile = path.join(p, config.barrel);

fs.writeFileSync(newFile, `${exportStatement}\n`);
log.fileWriteEvent(exportStatement, newFile, 'NEW');
const fileExists = fs.existsSync(newFile);
if (fileExists) {
fs.appendFileSync(newFile, `${exportStatement}\n`);
} else {
fs.writeFileSync(newFile, `${exportStatement}\n`);
}
log.fileWriteEvent(exportStatement, newFile, fileExists ? 'UPDATE' : 'NEW');
} else {
log.error(`No barrel file named '${config.barrel}' found in tree. No --create/-c argument set either.`);
const possiblePlaces = getPossibilities(directory, config.barrel);
const closestBarrel = possiblePlaces.find(path => fs.existsSync(path));
if (closestBarrel !== undefined) {
const closestBarrelPath = strings.trimEnd(config.barrel, closestBarrel);
const fromPath = strings.trimStart(closestBarrelPath, directory + moduleName);
const exportStatement = strings.exportStatement(fromPath);
fs.appendFileSync(closestBarrel, `${exportStatement}\n`);
log.fileWriteEvent(exportStatement, closestBarrel);
} else {
log.error(`No barrel file named '${config.barrel}' found in tree. No --create/-c argument set either.`);
}
}

@@ -73,0 +82,0 @@ }

{
"name": "ng-barrel",
"version": "1.0.0",
"version": "1.1.0",
"description": "CLI tool to add generated Angular files to barrel files",

@@ -5,0 +5,0 @@ "main": "ng-barrel.js",

@@ -48,3 +48,2 @@ [![npm version](https://badge.fury.io/js/ng-barrel.svg)](https://badge.fury.io/js/ng-barrel)

export * from './example/example.component';
```

@@ -69,6 +68,10 @@

You can also pass `--create / -c` to specify where a barrel file should be created,
when no barrel file was found in the whole tree!
It takes a relative path, which will be combined with the path of the newly added element.
You can also pass `--create / -c` to specify where a barrel file should be created.
If this option is specified it takes priority over tree traversing.
If a barrel file at the specified path already exists, the export will be appended.
Otherwise a new file will be written.
`--create` takes a relative path, which will be combined with the path of the newly added files.
```bash

@@ -75,0 +78,0 @@ $ ng g s foo/services/Data data | ng-barrel -c ./

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