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

css-modules-typescript-loader

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-modules-typescript-loader - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

81

index.js

@@ -20,3 +20,3 @@ const fs = require('fs');

);
}
};

@@ -39,4 +39,17 @@ const cssModuleToNamedExports = cssModuleKeys => {

const isFileNotFound = err => err && err.code === 'ENOENT';
const makeDoneHandlers = (callback, content, rest) => ({
failed: e => callback(e),
success: () => callback(null, content, ...rest)
});
const makeFileHandlers = filename => ({
read: handler => fs.readFile(filename, { encoding: 'utf-8' }, handler),
write: (content, handler) =>
fs.writeFile(filename, content, { encoding: 'utf-8' }, handler)
});
module.exports = function(content, ...rest) {
const callback = this.async();
const { failed, success } = makeDoneHandlers(this.async(), content, rest);

@@ -50,2 +63,3 @@ const filename = this.resourcePath;

const cssModuleInterfaceFilename = filenameToTypingsFilename(filename);
const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);

@@ -67,41 +81,42 @@ const keyRegex = /"([^\\"]+)":/g;

if (mode === 'verify') {
fs.readFile(
cssModuleInterfaceFilename,
{ encoding: 'utf-8' },
(err, fileContents) => {
if (err) {
const error =
err.code === 'ENOENT'
? getNoDeclarationFileError({
filename: cssModuleInterfaceFilename
})
: err;
return callback(error);
}
read((err, fileContents) => {
if (isFileNotFound(err)) {
return failed(
getNoDeclarationFileError({
filename: cssModuleInterfaceFilename
})
);
}
if (cssModuleDefinition !== fileContents) {
return callback(getTypeMismatchError({
if (err) {
return failed(err);
}
if (cssModuleDefinition !== fileContents) {
return failed(
getTypeMismatchError({
filename: cssModuleInterfaceFilename,
expected: cssModuleDefinition,
actual: fileContents
}));
}
})
);
}
return callback(null, content, ...rest);
}
);
return success();
});
} else {
fs.writeFile(
cssModuleInterfaceFilename,
cssModuleDefinition,
{ encoding: 'utf-8' },
err => {
if (err) {
return callback(err);
} else {
return callback(null, content, ...rest);
}
read((_, fileContents) => {
if (cssModuleDefinition !== fileContents) {
write(cssModuleDefinition, err => {
if (err) {
failed(err);
} else {
success();
}
});
} else {
success();
}
);
});
}
};
{
"name": "css-modules-typescript-loader",
"version": "1.1.0",
"version": "1.1.1",
"description": "Webpack loader to create TypeScript declarations for CSS Modules",

@@ -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