Socket
Socket
Sign inDemoInstall

broccoli-module-normalizer

Package Overview
Dependencies
32
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

77

index.js

@@ -7,4 +7,4 @@ 'use strict';

const symlinkOrCopy = require('symlink-or-copy');
const walkSync = require('walk-sync');
const rimraf = require('rimraf');
const MergeTrees = require('merge-trees');

@@ -24,3 +24,3 @@ module.exports = class ModuleNormalizer extends Plugin {

build() {
if (this._hasRan && symlinkOrCopy.canSymlink) {
if (this._noChange && symlinkOrCopy.canSymlink) {
return;

@@ -31,13 +31,18 @@ }

let outputPath = this.outputPath;
let inputModulesPath = path.join(inputPath, 'modules');
let outputModulesPath = path.join(outputPath, 'modules');
let modulesPath = path.join(inputPath, 'modules');
let modules;
if (fs.existsSync(modulesPath)) {
modules = fs.readdirSync(modulesPath);
if (!fs.existsSync(inputModulesPath)) {
if (this._hasRan) {
fs.unlinkSync(outputPath);
} else {
fs.rmdirSync(outputPath);
}
if (this.options.callback) {
this.options.callback();
}
} else {
modules = [];
symlinkOrCopy.sync(inputPath, outputPath);
this._noChange = true;
this._hasRan = true;
return;
}

@@ -50,41 +55,19 @@

let dirs = fs.readdirSync(inputPath).filter(dir => dir !== 'modules');
let intersection = dirs.filter(dir => modules.indexOf(dir) !== -1);
let modulesOnly = modules.filter(dir => dirs.indexOf(dir) === -1);
let nonModules = dirs.filter(dir => modules.indexOf(dir) === -1);
for (let dir of intersection) {
let files = [[dir, dir]]
.concat(walkSync(path.join(modulesPath, dir)).map(file => [path.join('modules', dir, file), path.join(dir, file)]))
.concat(walkSync(path.join(inputPath, dir)).map(file => [path.join(dir, file), path.join(dir, file)]));
let visited = new Set();
for (let pair of files) {
if (visited.has(pair[1])) {
continue;
}
let inputFilePath = path.join(inputPath, pair[0]);
let outputFilePath = path.join(outputPath, pair[1]);
if (fs.statSync(inputFilePath).isDirectory()) {
fs.mkdirSync(outputFilePath);
} else {
symlinkOrCopy.sync(inputFilePath, outputFilePath);
}
visited.add(pair[1]);
let mergeTrees = new MergeTrees(
[
inputPath,
inputModulesPath
],
this.outputPath,
{
overwrite: true,
annotation: this.options.annotation
}
}
);
mergeTrees.merge();
let files = modulesOnly.map(file => [path.join('modules', file), file])
.concat(nonModules.map(file => [file, file]));
rimraf.sync(outputModulesPath);
for (let pair of files) {
let inputDirPath = path.join(inputPath, pair[0]);
let outputDirPath = path.join(outputPath, pair[1]);
symlinkOrCopy.sync(inputDirPath, outputDirPath);
if (this.options.callback) {
this.options.callback();
}

@@ -91,0 +74,0 @@

{
"name": "broccoli-module-normalizer",
"version": "1.2.0",
"version": "1.3.0",
"description": "Broccoli plugin to remove `modules/` subdirectory from legacy ember-cli addons.",

@@ -11,3 +11,3 @@ "main": "index.js",

"prelint": "eslint --version",
"lint": "eslint index.js test/index.js"
"lint": "eslint index.js test"
},

@@ -21,8 +21,11 @@ "contributors": [

"license": "MIT",
"engines": {
"node": ">=4"
},
"files": [],
"dependencies": {
"broccoli-plugin": "^1.3.0",
"merge-trees": "^1.0.1",
"rimraf": "^2.6.2",
"symlink-or-copy": "^1.1.8",
"walk-sync": "^0.3.2"
"symlink-or-copy": "^1.1.8"
},

@@ -36,2 +39,3 @@ "devDependencies": {

"eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-node": "^6.0.0",
"eslint-plugin-prefer-let": "^1.0.1",

@@ -38,0 +42,0 @@ "mocha": "^5.0.0",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc