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

distinguish

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

distinguish - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

out/index.js

136

out/cli.js

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

var distinguisher_1 = require("./distinguisher");
var version = require('../package.json').version;
var VALID_INCREMENTERS = ['simple', 'module', 'minimal'];

@@ -42,4 +41,11 @@ var EMPTY_CONFIG = "exports.default = {\n incrementer: 'simple', // the incrementer to use ([minimal, simple, module])\n types: ['cls', 'id'], // the types to rename (e.g. CSS classes, IDs)\n\n inputDir: 'src/', // the input directory to use\n outputDir: 'out/', // the output directory to use\n\n exclude: [], // a regular expression array describing files to exclude from renaming\n};\n";

var CLIParser = /** @class */ (function () {
function CLIParser(stream, parent) {
function CLIParser(stream, fs, requireFn, dirname, join, cwd, returnOptsOnly, parent) {
if (returnOptsOnly === void 0) { returnOptsOnly = false; }
this.stream = stream;
this.fs = fs;
this.requireFn = requireFn;
this.dirname = dirname;
this.join = join;
this.cwd = cwd;
this.returnOptsOnly = returnOptsOnly;
this.parent = parent;

@@ -49,3 +55,5 @@ }

if (this.stream.length == 0) {
log_1.logStyle(log_1.FAIL, "Expected additional arguments\n");
if (!this.returnOptsOnly) {
log_1.logStyle(log_1.FAIL, "Expected additional arguments\n");
}
return false;

@@ -57,3 +65,5 @@ }

if (this.stream.length != 0) {
log_1.logStyle(log_1.FAIL, "Encountered extraneous arguments: " + this.stream + "\n");
if (!this.returnOptsOnly) {
log_1.logStyle(log_1.FAIL, "Encountered extraneous arguments: " + this.stream + "\n");
}
return false;

@@ -105,3 +115,3 @@ }

var noOpts = this.stream.length == 0;
var opts = {};
var opts = { configFile: DEFAULT_CONFIG_FN };
while (this.stream.length > 0) {

@@ -111,4 +121,3 @@ // Go through expectations.

if (!this.moreArguments()) {
this.showUsage();
return;
return this.showUsage();
}

@@ -118,5 +127,6 @@ var incrementer = this.stream[0];

if (VALID_INCREMENTERS.indexOf(incrementer) == -1) {
log_1.logStyle(log_1.FAIL, "Expected an incrementer in the set " + VALID_INCREMENTERS + "\n");
this.showUsage();
return;
if (!this.returnOptsOnly) {
log_1.logStyle(log_1.FAIL, "Expected an incrementer in the set " + VALID_INCREMENTERS + "\n");
}
return this.showUsage();
}

@@ -129,4 +139,3 @@ opts.incrementer = incrementer;

if (!this.moreArguments()) {
this.showUsage();
return;
return this.showUsage();
}

@@ -140,4 +149,3 @@ opts.types = this.stream[0].split(',');

if (!this.moreArguments()) {
this.showUsage();
return;
return this.showUsage();
}

@@ -151,4 +159,3 @@ opts.inputDir = this.stream[0];

if (!this.moreArguments()) {
this.showUsage();
return;
return this.showUsage();
}

@@ -162,4 +169,3 @@ opts.outputDir = this.stream[0];

if (!this.moreArguments()) {
this.showUsage();
return;
return this.showUsage();
}

@@ -205,4 +211,3 @@ opts.exclude = this.stream[0].split(',').map(function (x) { return new RegExp(x); });

if (!this.moreArguments() || !expectConfig) {
this.showUsage();
return;
return this.showUsage();
}

@@ -228,4 +233,12 @@ opts.configFile = this.stream[0];

// Load in the config file.
opts.configFile = path_1["default"].join(process.cwd(), opts.configFile);
var settings = require(opts.configFile)["default"];
if (!this.returnOptsOnly) {
opts.configFile = path_1["default"].join(process.cwd(), opts.configFile);
}
var settings = this.requireFn(opts.configFile)["default"];
if (settings == undefined) {
if (!this.returnOptsOnly) {
log_1.logStyle(log_1.FAIL, "Unable to read in " + opts.configFile + ".\n \nMaybe you need to create a config file first by running:\n\n distinguish init\n");
}
return this.showUsage();
}
if (opts.incrementer == null)

@@ -243,10 +256,12 @@ opts.incrementer = settings.incrementer;

// Run time.
console.log('Run settings:\n', opts);
console.log();
var distinguisher = new distinguisher_1.Distinguisher(opts);
distinguisher.run();
if (!this.returnOptsOnly) {
console.log('Run settings:\n', opts);
console.log();
var distinguisher = new distinguisher_1.Distinguisher(opts, fs_1["default"], path_1["default"].dirname);
distinguisher.run();
}
return { opts: opts };
};
RenameCLI.prototype.showUsage = function () {
console.log("Usage: " + BINARY_NAME + " rename [options]\n\n rename and namespace files recursively in a directory\n\nOptions:\n -c, --config [fn] Load all the settings from a config file.\n (default if no value passed: " + DEFAULT_CONFIG_FN + ")\n\nConfig options / overrides:\n -n, --incrementer <str> Specify the incrementer to use.\n Options are 'simple', 'module', or 'minimal'\n (default if no config specified: simple)\n\n -t, --types <list> Specify a list of types to rename\n (default if no config specified: cls,id)\n\n -i, --inputDir <dir> The input directory to use\n (this arg is mandatory if no config is specified)\n\n -o, --outputDir <dir> The output directory to use\n (this arg is mandatory if no config is specified)\n\n -e, --exclude <list> Regular expression of paths to exclude renaming.\n It is recommended to set this in a config file to\n have more control.\n (default: empty list)\n");
process.exit(1);
return this.parent.showUsage();
};

@@ -264,16 +279,22 @@ return RenameCLI;

fn = this.stream[0];
if (fn.startsWith('-'))
return this.showUsage();
this.advance();
if (!this.noMoreArguments()) {
this.showUsage();
return;
}
if (!this.noMoreArguments())
return this.showUsage();
}
var startTime = Date.now();
fs_1["default"].writeFileSync(fn, EMPTY_CONFIG);
var deltaTime = Date.now() - startTime;
log_1.logStyle(log_1.SUCCESS, "Wrote config to " + fn + " in " + deltaTime / 1000 + "s");
if (!this.returnOptsOnly) {
var startTime = Date.now();
fs_1["default"].writeFileSync(fn, EMPTY_CONFIG);
var deltaTime = Date.now() - startTime;
log_1.logStyle(log_1.SUCCESS, "Wrote config to " + fn + " in " + deltaTime / 1000 + "s");
}
return { initFn: fn };
};
InitCLI.prototype.showUsage = function () {
console.log("Usage: " + BINARY_NAME + " init <fn>\n\n create a default distinguish config file\n\nArguments:\n fn The file to create.\n (default: " + DEFAULT_CONFIG_FN + ")\n");
process.exit(1);
if (!this.returnOptsOnly) {
console.log("Usage: " + BINARY_NAME + " init <fn>\n\n create a default distinguish config file\n\nArguments:\n fn The file to create.\n (default: " + DEFAULT_CONFIG_FN + ")\n");
process.exit(1);
}
return { showUsage: 'init' };
};

@@ -284,4 +305,5 @@ return InitCLI;

__extends(CLI, _super);
function CLI() {
var _this = _super.call(this, process.argv.slice(2)) || this;
function CLI(version, args, fs, requireFn, dirname, join, cwd, returnOptsOnly) {
if (returnOptsOnly === void 0) { returnOptsOnly = false; }
var _this = _super.call(this, args, fs, requireFn, dirname, join, cwd, returnOptsOnly) || this;
_this.version = version;

@@ -299,7 +321,4 @@ return _this;

// Try to consume sub-commands.
if (this.consumeOption(['rename'])) {
return new RenameCLI(this.stream.slice(1), this).process();
}
if (this.consumeOption(['init'])) {
return new InitCLI(this.stream.slice(1), this).process();
return new InitCLI(this.stream.slice(1), this.fs, this.requireFn, this.dirname, this.join, this.cwd, this.returnOptsOnly, this).process();
}

@@ -310,24 +329,33 @@ if (this.consumeOption(['help'])) {

if (this.consumeOption(['rename'])) {
return new RenameCLI(this.stream.slice(1), this).showUsage();
return new RenameCLI(this.stream.slice(1), this.fs, this.requireFn, this.dirname, this.join, this.cwd, this.returnOptsOnly, this).showUsage();
}
if (this.consumeOption(['init'])) {
return new InitCLI(this.stream.slice(1), this).showUsage();
return new InitCLI(this.stream.slice(1), this.fs, this.requireFn, this.dirname, this.join, this.cwd, this.returnOptsOnly, this).showUsage();
}
return this.showUsage();
}
this.showUsage();
return new RenameCLI(this.stream, this.fs, this.requireFn, this.dirname, this.join, this.cwd, this.returnOptsOnly, this).process();
};
CLI.prototype.showVersion = function () {
console.log(this.version);
if (!this.returnOptsOnly)
console.log(this.version);
return { showVersion: true };
};
CLI.prototype.showUsage = function () {
console.log("Usage: " + BINARY_NAME + " <command> [options]\n\nCommands:\n rename [options] rename and namespace files\n recursively in a directory\n\n init <fn=" + DEFAULT_CONFIG_FN + "> create a config file\n\n help [command] get options for a given command\n\nOptions:\n -v, --version print the version\n -h, --help, --usage print this message\n --splash show a fun splash screen\n");
process.exit(1);
if (!this.returnOptsOnly) {
console.log("Usage: " + BINARY_NAME + " <command> [options]\n\nCommands:\n rename [options] rename and namespace files\n recursively in a directory\n\n init <fn=" + DEFAULT_CONFIG_FN + "> create a config file\n\n help [command] get options for a given command\n\nOptions:\n -v, --version print the version\n -h, --help, --usage print this message\n --splash show a fun splash screen\n");
process.exit(1);
}
return { showUsage: 'base' };
};
CLI.prototype.showSplash = function () {
console.log(SPLASH_SCREEN);
log_1.logStyle(log_1.BOLD, 'Effortless renaming, minification, and namespacing');
log_1.logStyle(log_1.BOLD, 'for CSS class names, IDs, and just about anything else.\n');
if (!this.returnOptsOnly) {
console.log(SPLASH_SCREEN);
log_1.logStyle(log_1.BOLD, 'Effortless renaming, minification, and namespacing');
log_1.logStyle(log_1.BOLD, 'for CSS class names, IDs, and just about anything else.\n');
}
return { showSplash: true };
};
return CLI;
}(CLIParser));
new CLI().process();
exports.CLI = CLI;

@@ -28,8 +28,3 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
var fs_1 = __importDefault(require("fs"));
var path_1 = __importDefault(require("path"));
var renamer_1 = require("./renamer");

@@ -41,8 +36,8 @@ var namespec_1 = require("./namespec");

// Adapted from https://stackoverflow.com/a/34509653
function ensureDirectoryExistence(filePath) {
var dirname = path_1["default"].dirname(filePath);
if (fs_1["default"].existsSync(dirname))
function ensureDirectoryExistence(filePath, dirnameFn, fs) {
var dirname = dirnameFn(filePath);
if (fs.existsSync(dirname))
return;
ensureDirectoryExistence(dirname);
fs_1["default"].mkdirSync(dirname);
ensureDirectoryExistence(dirname, dirnameFn, fs);
fs.mkdirSync(dirname);
}

@@ -63,4 +58,6 @@ function getAllMatches(regex, str) {

var Distinguisher = /** @class */ (function () {
function Distinguisher(distinguishConfig) {
function Distinguisher(distinguishConfig, fs, dirnameFn) {
this.distinguishConfig = distinguishConfig;
this.fs = fs;
this.dirnameFn = dirnameFn;
var incrementer = incrementers[distinguishConfig.incrementer];

@@ -80,5 +77,5 @@ this.rootRenamer = new renamer_1.Renamer(incrementer, distinguishConfig.types);

var namespecPath = "" + dir + NAMESPEC;
if (fs_1["default"].existsSync(namespecPath)) {
if (this.fs.existsSync(namespecPath)) {
// Parse a namespec file to determine the renamer's new scope.
var namespec = new namespec_1.NamespecParser(fs_1["default"].readFileSync(namespecPath).toString()).parse();
var namespec = new namespec_1.NamespecParser(this.fs.readFileSync(namespecPath).toString()).parse();
// Set the namespace.

@@ -151,3 +148,3 @@ renamer = renamer.namespace(renamer_1.Renamer.pathSpecToParts(namespec.namespace));

}
var files = fs_1["default"].readdirSync(dir == '' ? '.' : dir);
var files = this.fs.readdirSync(dir == '' ? '.' : dir);
files.forEach(function (file) {

@@ -170,4 +167,4 @@ var e_6, _a;

}
if (fs_1["default"].statSync(fn).isDirectory()) {
filelist = _this.walkSync(fn + "/", "" + outDir + file, renamer, filelist);
if (_this.fs.statSync(fn).isDirectory()) {
filelist = _this.walkSync("" + (fn + (fn.endsWith('/') ? '' : '/')), "" + outDir + file, renamer, filelist);
}

@@ -190,3 +187,3 @@ else {

var _f = _e.value, inputFile = _f.inputFile, outputFile = _f.outputFile, renamer = _f.renamer;
var contents = fs_1["default"].readFileSync(inputFile).toString();
var contents = this.fs.readFileSync(inputFile).toString();
var hadMatches = false;

@@ -221,4 +218,4 @@ try {

}
ensureDirectoryExistence(outputFile);
fs_1["default"].writeFileSync(outputFile, contents.toString());
ensureDirectoryExistence(outputFile, this.dirnameFn, this.fs);
this.fs.writeFileSync(outputFile, contents.toString());
}

@@ -225,0 +222,0 @@ }

@@ -28,5 +28,35 @@ "use strict";

};
Tester.getType = function (obj) {
if (Array.isArray(obj)) {
return 'array';
}
else if (obj instanceof RegExp) {
return 're';
}
else if (obj.constructor == Object) {
return 'object';
}
else {
return 'primitive';
}
};
Tester.prototype.assertEquals = function (arg1, arg2) {
if (arg1 != arg2)
throw new Error("Expected " + arg1 + " to equal " + arg2);
var type1 = Tester.getType(arg1);
var type2 = Tester.getType(arg2);
if (type1 != type2) {
throw new Error("Types of " + arg1 + " and " + arg2 + " are not the same: " + type1 + " vs. " + type2);
}
if (type1 == 'array') {
this.assertArrayEquals(arg1, arg2);
}
else if (type1 == 'object') {
this.assertObjectEquals(arg1, arg2);
}
else if (type1 == 're') {
this.assertEquals(arg1.source, arg2.source);
}
else {
if (arg1 != arg2)
throw new Error("Expected " + arg1 + " to equal " + arg2);
}
};

@@ -33,0 +63,0 @@ Tester.prototype.assertArrayEquals = function (arg1, arg2) {

"use strict";
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
exports.__esModule = true;

@@ -7,2 +17,5 @@ var renamer_1 = require("./renamer");

var incrementer_1 = require("./incrementer");
var virtual_fs_1 = require("./virtual-fs");
var distinguisher_1 = require("./distinguisher");
var cli_1 = require("./cli");
var t = new tester_1.Tester();

@@ -250,1 +263,242 @@ t.test('testBasicNaming', function () {

});
t.test('virtualFsBasic', function () {
var fs = new virtual_fs_1.VirtualFs();
fs.writeFileSync('/hello.txt', 'hello world');
t.assertEquals(fs.readFileSync('/hello.txt').toString(), 'hello world');
t.assertArrayEquals(fs.readdirSync('/'), ['hello.txt']);
});
t.test('virtualFsListDir', function () {
var fs = new virtual_fs_1.VirtualFs();
fs.writeFileSync('/src/index.html', '');
fs.writeFileSync('/src/style.css', '');
fs.writeFileSync('/src/component/component.html', '');
fs.writeFileSync('/src/component/component.css', '');
fs.writeFileSync('/src/component/toggle/toggle.css', '');
fs.writeFileSync('/src/component/toggle/tests/style/test.js', '');
fs.writeFileSync('/out/module/component/test.txt', '');
t.assertArrayEquals(fs.readdirSync('/'), ['out/', 'src/']);
t.assertArrayEquals(fs.readdirSync('/src/'), [
'component/',
'index.html',
'style.css',
]);
t.assertArrayEquals(fs.readdirSync('/src/component/'), [
'component.css',
'component.html',
'toggle/',
]);
t.assertArrayEquals(fs.readdirSync('/src/component/toggle/'), [
'tests/',
'toggle.css',
]);
t.assertArrayEquals(fs.readdirSync('/src/component/toggle/tests/'), ['style/']);
t.assertArrayEquals(fs.readdirSync('/src/component/toggle/tests/style/'), [
'test.js',
]);
t.assertArrayEquals(fs.readdirSync('/out/'), ['module/']);
t.assertArrayEquals(fs.readdirSync('/out/module/'), ['component/']);
t.assertArrayEquals(fs.readdirSync('/out/module/component/'), ['test.txt']);
});
t.test('distinguisherBasic', function () {
var fs = new virtual_fs_1.VirtualFs();
fs.writeFileSync('/src/style.css', '._cls-content { color: gray; }');
var config = {
inputDir: '/src/',
outputDir: '/out/',
incrementer: 'minimal',
types: ['cls', 'id'],
exclude: []
};
var d = new distinguisher_1.Distinguisher(config, fs, fs.dirname);
d.run();
t.assertArrayEquals(fs.readdirSync('/'), ['out/', 'src/']);
t.assertArrayEquals(fs.readdirSync('/out/'), ['style.css']);
t.assertEquals(fs.readFileSync('/out/style.css').toString(), '.a { color: gray; }');
});
t.test('distinguisherClsAndIdBasic', function () {
var fs = new virtual_fs_1.VirtualFs();
fs.writeFileSync('/src/index.html', '<div id="_id-content" class="_cls-content">Content here</div>');
fs.writeFileSync('/src/component/style.css', "\n ._cls-content {\n color: gray;\n }\n #_id-content {\n font-weight: bold;\n }");
var config = {
inputDir: '/src/',
outputDir: '/out/',
incrementer: 'minimal',
types: ['cls', 'id'],
exclude: []
};
var d = new distinguisher_1.Distinguisher(config, fs, fs.dirname);
d.run();
t.assertEquals(fs.readFileSync('/out/index.html').toString(), '<div id="a" class="a">Content here</div>');
t.assertEquals(fs.readFileSync('/out/component/style.css').toString(), "\n .a {\n color: gray;\n }\n #a {\n font-weight: bold;\n }");
});
function toggleSrcIndex(toggleClass) {
return "\n<link rel=\"stylesheet\" href=\"toggle/toggle.css\">\n\n<style>\n ." + toggleClass + " {\n background: green;\n }\n</style>\n\n<div class=\"" + toggleClass + "\"></div>\n\n<script src=\"toggle/toggle.js\"></script>";
}
function toggleToggleCss(toggleClass) {
return "\n ." + toggleClass + " {\n background: blue;\n }";
}
function toggleToggleJs(toggleClass) {
return "\n // Create a toggle element from scratch.\n const div = document.createElement('div');\n div.classList.add('" + toggleClass + "');\n \n // Code to render it.\n ...";
}
function toggleTest(initialClass, indexClass, cssClass, jsClass, playWithFiles) {
var fs = new virtual_fs_1.VirtualFs();
fs.writeFileSync('/src/index.html', toggleSrcIndex(initialClass));
fs.writeFileSync('/src/toggle/toggle.css', toggleToggleCss(initialClass));
fs.writeFileSync('/src/toggle/toggle.js', toggleToggleJs(initialClass));
if (playWithFiles != null)
playWithFiles(fs);
var config = {
inputDir: '/src/',
outputDir: '/out/',
incrementer: 'minimal',
types: ['cls', 'id'],
exclude: []
};
var d = new distinguisher_1.Distinguisher(config, fs, fs.dirname);
d.run();
t.assertEquals(fs.readFileSync('/out/index.html').toString(), toggleSrcIndex(indexClass));
t.assertEquals(fs.readFileSync('/out/toggle/toggle.css').toString(), toggleToggleCss(cssClass));
t.assertEquals(fs.readFileSync('/out/toggle/toggle.js').toString(), toggleToggleJs(jsClass));
}
t.test('distinguisherNamespaceClash', function () {
toggleTest('_cls-toggle', 'a', 'a', 'a');
});
t.test('distinguisherNamespaceFixComponent', function () {
toggleTest('_cls-toggle', 'a', 'b', 'b', function (fs) {
fs.writeFileSync('/src/toggle/.namespec', 'namespace toggle');
});
});
t.test('distinguisherNamespaceImport', function () {
toggleTest('_cls-toggle', 'a', 'a', 'a', function (fs) {
fs.writeFileSync('/src/toggle/.namespec', "namespace toggle\n\nfrom .. import\n cls\n toggle");
});
});
t.test('distinguisherNamespecReserve', function () {
toggleTest('_cls-toggle', 'b', 'c', 'c', function (fs) {
fs.writeFileSync('/src/toggle/.namespec', "namespace toggle\n\nreserve\n cls\n a");
});
});
function cli(argsString, fsInit) {
var fs = new virtual_fs_1.VirtualFs();
if (fsInit != null)
fsInit(fs);
return new cli_1.CLI(null, argsString.split(' ').filter(function (x) { return x.trim().length > 0; }), fs, fs.require.bind(fs), fs.dirname, fs.join, function () { return '/'; }, true).process();
}
t.test('distinguishCliShowDialogs', function () {
// Help
t.assertObjectEquals(cli('--help'), { showUsage: 'base' });
t.assertObjectEquals(cli('-h'), { showUsage: 'base' });
t.assertObjectEquals(cli('--usage'), { showUsage: 'base' });
t.assertObjectEquals(cli('help'), { showUsage: 'base' });
t.assertObjectEquals(cli('help init'), { showUsage: 'init' });
t.assertObjectEquals(cli('help rename'), { showUsage: 'base' });
t.assertObjectEquals(cli('--invalid-option'), { showUsage: 'base' });
t.assertObjectEquals(cli('rename --invalid-option'), { showUsage: 'base' });
// Version
t.assertObjectEquals(cli('-v'), { showVersion: true });
t.assertObjectEquals(cli('--version'), { showVersion: true });
// Splash
t.assertObjectEquals(cli('--splash'), { showSplash: true });
});
t.test('distinguishCliInit', function () {
t.assertObjectEquals(cli('init'), { initFn: 'distinguish.config.js' });
t.assertObjectEquals(cli('init config.js'), { initFn: 'config.js' });
t.assertObjectEquals(cli('init -o'), { showUsage: 'init' });
t.assertObjectEquals(cli('init config.js extraneous'), { showUsage: 'init' });
});
t.test('distinguishCliRenameNoConfig', function () {
var result = cli('');
// File won't exist yet.
t.assertEquals(result.showUsage, 'base');
});
function getConfig(incrementer, types, inputDir, outputDir, exclude) {
if (incrementer === void 0) { incrementer = 'simple'; }
if (types === void 0) { types = ['cls', 'id']; }
if (inputDir === void 0) { inputDir = 'src/'; }
if (outputDir === void 0) { outputDir = 'out/'; }
if (exclude === void 0) { exclude = []; }
return "exports.default = {\n incrementer: '" + incrementer + "', // the incrementer to use ([minimal, simple, module])\n types: " + JSON.stringify(types) + ", // the types to rename (e.g. CSS classes, IDs)\n \n inputDir: '" + inputDir + "', // the input directory to use\n outputDir: '" + outputDir + "', // the output directory to use\n \n exclude: " + JSON.stringify(exclude) + ", // a regular expression array describing files to exclude from renaming\n };\n ";
}
t.test('distinguishCliRenameWithConfig', function () {
var e_1, _a;
try {
for (var _b = __values([
'',
'-c',
'-c distinguish.config.js',
'--config',
'--config distinguish.config.js',
]), _c = _b.next(); !_c.done; _c = _b.next()) {
var cmd = _c.value;
var result = cli('', function (fs) {
fs.writeFileSync('distinguish.config.js', getConfig());
});
// Let's check we get a matching config.
t.assert(result.opts);
var opts = result.opts;
t.assertEquals(opts, {
configFile: 'distinguish.config.js',
incrementer: 'simple',
types: ['cls', 'id'],
inputDir: 'src/',
outputDir: 'out/',
exclude: []
});
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
});
t.test('distinguishCliRenameWithConfigDifferentFile', function () {
var e_2, _a;
try {
for (var _b = __values([
'-c specification/config.js',
'--config specification/config.js',
]), _c = _b.next(); !_c.done; _c = _b.next()) {
var cmd = _c.value;
var result = cli(cmd, function (fs) {
fs.writeFileSync('specification/config.js', getConfig());
});
// Let's check we get a matching config.
t.assert(result.opts);
var opts = result.opts;
t.assertEquals(opts, {
configFile: 'specification/config.js',
incrementer: 'simple',
types: ['cls', 'id'],
inputDir: 'src/',
outputDir: 'out/',
exclude: []
});
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
});
t.test('distinguishCliRenameWithOverrides', function () {
var result = cli('-c spec/settings/config.js -n minimal -t dog,cat,hen -i input/src/ -o dest/ -e dog,cat', function (fs) {
fs.writeFileSync('spec/settings/config.js', getConfig());
});
// Let's check we get a matching config.
t.assert(result.opts);
var opts = result.opts;
t.assertEquals(opts, {
configFile: 'spec/settings/config.js',
incrementer: 'minimal',
types: ['dog', 'cat', 'hen'],
inputDir: 'input/src/',
outputDir: 'dest/',
exclude: [/dog/, /cat/]
});
});
{
"name": "distinguish",
"version": "0.1.2",
"version": "0.1.3",
"description": "Effortless renaming, minification, and namespacing for CSS class names, IDs, and just about anything else.",

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