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

pug-slides-loader

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pug-slides-loader - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

32

index.js

@@ -1,1 +0,31 @@

!function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){const n=t(1),o=t(2);e.exports=function(e){let r=e;const t=this.async(),i=this.query.from;if(!i)throw Error("You need to specify slides root folder! Eg.: ./src/slides/");o.readdir(i,(o,u)=>{const l=e.match(/(import.*from.*;)(?!.*\1)/g),c=l&&l[l.length-1]||null;let f=c&&c+"\n"||"",s="";u.forEach((e,r)=>{/slide.*\.pug$/.test(e)&&(f+=`import revealSlide${r} from '${n.resolve(i,e)}';\n`,s+="${revealSlide"+r+"}\n")}),r=c?r.replace(c,f):f+r,r=r.replace("\x3c!--inject:slides--\x3e",s),t(null,r)})},e.exports.raw=!0},function(e,r){e.exports=require("path")},function(e,r){e.exports=require("fs")}]);
/* eslint-disable no-useless-concat */
const path = require('path');
const fs = require('fs');
module.exports = function RevealSliderLoader(source) {
let newSource = source;
const callback = this.async();
const fromPath = this.query.from;
if (!fromPath) throw Error('You need to specify slides root folder! Eg.: ./src/slides/');
fs.readdir(fromPath, (err, files) => {
const regex = /(import.*from.*;)(?!.*\1)/g;
const imports = source.match(regex);
const lastImport = (imports && imports[imports.length - 1]) || null;
let extendedImport = (lastImport && `${lastImport}\n`) || '';
let stringTemplatesImports = '';
files.forEach((file, i) => {
if (/slide.*\.pug$/.test(file)) {
extendedImport += `import revealSlide${i} from '${path.resolve(fromPath, file)}';\n`;
stringTemplatesImports += '${' + `revealSlide${i}` + '}\n';
}
});
if (lastImport) {
newSource = newSource.replace(lastImport, extendedImport);
} else {
newSource = extendedImport + newSource;
}
newSource = newSource.replace('<!--inject:slides-->', stringTemplatesImports);
callback(null, newSource);
});
};

2

package.json
{
"name": "pug-slides-loader",
"version": "1.0.2",
"version": "1.0.3",
"description": "Simple Webpack loader for Reveal.js slides (.pug files) to fast inject them in one place",

@@ -5,0 +5,0 @@ "main": "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