Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var debug = process.env.DEBUG_JSBEAUTIFY || process.env.JSBEAUTIFY_DEBUG ? function() {
console.error.apply(console, arguments);
} : function() {};
var fs = require('fs'),
cc = require('config-chain'),
beautify = require('../index'),
mkdirp = require('mkdirp'),
nopt = require('nopt');
nopt.invalidHandler = function(key, val) {
throw new Error(key + " was invalid with value \"" + val + "\"");
};
nopt.typeDefs.brace_style = {
type: "brace_style",
validate: function(data, key, val) {
data[key] = val;
// TODO: expand-strict is obsolete, now identical to expand. Remove in future version
// TODO: collapse-preserve-inline is obselete, now identical to collapse,preserve-inline = true. Remove in future version
var validVals = ["collapse", "collapse-preserve-inline", "expand", "end-expand", "expand-strict", "none", "preserve-inline"];
var valSplit = val.split(/[^a-zA-Z0-9_\-]+/); //Split will always return at least one parameter
for (var i = 0; i < valSplit.length; i++) {
if (validVals.indexOf(valSplit[i]) === -1) {
return false;
}
}
return true;
}
};
var path = require('path'),
var debug = process.env.DEBUG_JSBEAUTIFY || process.env.JSBEAUTIFY_DEBUG ? function() {
console.error.apply(console, arguments);
} : function() {};
var fs = require('fs'),
cc = require('config-chain'),
beautify = require('../index'),
mkdirp = require('mkdirp'),
nopt = require('nopt'),
glob = require('glob');
nopt.invalidHandler = function(key, val) {
throw new Error(key + " was invalid with value \"" + val + "\"");
};
nopt.typeDefs.brace_style = {
type: "brace_style",
validate: function(data, key, val) {
data[key] = val;
// TODO: expand-strict is obsolete, now identical to expand. Remove in future version
// TODO: collapse-preserve-inline is obselete, now identical to collapse,preserve-inline = true. Remove in future version
var validVals = ["collapse", "collapse-preserve-inline", "expand", "end-expand", "expand-strict", "none", "preserve-inline"];
var valSplit = val.split(/[^a-zA-Z0-9_\-]+/); //Split will always return at least one parameter
for (var i = 0; i < valSplit.length; i++) {
if (validVals.indexOf(valSplit[i]) === -1) {
return false;
}
}
return true;
}
};
var path = require('path'),
*/
var debug = process.env.DEBUG_JSBEAUTIFY || process.env.JSBEAUTIFY_DEBUG ? function() {
console.error.apply(console, arguments);
} : function() {};
var fs = require('fs'),
cc = require('config-chain'),
beautify = require('../index'),
mkdirp = require('mkdirp'),
nopt = require('nopt');
nopt.invalidHandler = function(key, val, types) {
throw new Error(key + " was invalid with value \"" + val + "\"");
}
nopt.typeDefs.brace_style = {
type: "brace_style",
validate: function(data, key, val) {
data[key] = val;
// TODO: expand-strict is obsolete, now identical to expand. Remove in future version
// TODO: collapse-preserve-inline is obselete, now identical to collapse,preserve-inline = true. Remove in future version
var validVals = ["collapse", "collapse-preserve-inline", "expand", "end-expand", "expand-strict", "none", "preserve-inline"];
var valSplit = val.split(/[^a-zA-Z0-9_\-]+/); //Split will always return at least one parameter
for (var i = 0; i < valSplit.length; i++) {
if (validVals.indexOf(valSplit[i]) === -1) {
return false;
}
}
return true;
}
};
var path = require('path'),
// defaults, types, and shorthands.
var path = require("path");
var url = require("url");
var Stream = require("stream").Stream;
var semver = require("semver");
var stableFamily = semver.parse(process.version);
var os = require("os");
var nopt = require("nopt");
var log = require("./log");
nopt.typeDefs.semver = { type: semver, validate: validateSemver };
function validateSemver(data, k, val) {
if (!semver.valid(val)) {
return false;
}
data[k] = semver.valid(val);
}
nopt.invalidHandler = function(k, val) {
log.warn(k + "=" + JSON.stringify(val), "invalid config");
};
if (!stableFamily || (+stableFamily[2] % 2)) {
stableFamily = null;
} else {
stableFamily = stableFamily[1] + "." + stableFamily[2];
}
function validateTag (data, k, val) {
val = ('' + val).trim()
if (!val || semver.validRange(val)) return false
data[k] = val
}
function validateStream (data, k, val) {
if (!(val instanceof Stream)) return false
data[k] = val
}
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
nopt.typeDefs.Octal = { type: Octal, validate: validateOctal }
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
// Don't let --tag=1.2.3 ever be a thing
var tag = {}
nopt.typeDefs.tag = { type: tag, validate: validateTag }
nopt.invalidHandler = function (k, val, type) {
log.warn("invalid config", k + "=" + JSON.stringify(val))
if (Array.isArray(type)) {
if (type.indexOf(url) !== -1) type = url
else if (type.indexOf(path) !== -1) type = path
}
switch (type) {
case tag:
log.warn("invalid config", "Tag must not be a SemVer range")
function Umask () {}
function validateUmask (data, k, val) {
return umask.validate(data, k, val)
}
function validateSemver (data, k, val) {
if (!semver.valid(val)) return false
data[k] = semver.valid(val)
}
function validateStream (data, k, val) {
if (!(val instanceof Stream)) return false
data[k] = val
}
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
nopt.typeDefs.Umask = { type: Umask, validate: validateUmask }
nopt.invalidHandler = function (k, val, type) {
log.warn("invalid config", k + "=" + JSON.stringify(val))
if (Array.isArray(type)) {
if (type.indexOf(url) !== -1) type = url
else if (type.indexOf(path) !== -1) type = path
}
switch (type) {
case Umask:
log.warn("invalid config", "Must be umask, octal number in range 0000..0777")
break
case url:
return umask.validate(data, k, val)
}
function validateSemver (data, k, val) {
if (!semver.valid(val)) return false
data[k] = semver.valid(val)
}
function validateStream (data, k, val) {
if (!(val instanceof Stream)) return false
data[k] = val
}
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
nopt.typeDefs.Umask = { type: Umask, validate: validateUmask }
nopt.invalidHandler = function (k, val, type) {
log.warn('invalid config', k + '=' + JSON.stringify(val))
if (Array.isArray(type)) {
if (type.indexOf(url) !== -1) type = url
else if (type.indexOf(path) !== -1) type = path
}
switch (type) {
case Umask:
log.warn('invalid config', 'Must be umask, octal number in range 0000..0777')
break
case url:
log.warn('invalid config', "Must be a full url with 'http://'")
break
function Umask () {}
function validateUmask (data, k, val) {
return umask.validate(data, k, val)
}
function validateSemver (data, k, val) {
if (!semver.valid(val)) return false
data[k] = semver.valid(val)
}
function validateStream (data, k, val) {
if (!(val instanceof Stream)) return false
data[k] = val
}
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
nopt.typeDefs.Umask = { type: Umask, validate: validateUmask }
nopt.invalidHandler = function (k, val, type) {
log.warn('invalid config', k + '=' + JSON.stringify(val))
if (Array.isArray(type)) {
if (type.indexOf(url) !== -1) type = url
else if (type.indexOf(path) !== -1) type = path
}
switch (type) {
case Umask:
log.warn('invalid config', 'Must be umask, octal number in range 0000..0777')
break
case url:
data[k] = "0" + parseInt(val, 8).toString(8)
}
}
function validateSemver (data, k, val) {
if (!semver.valid(val)) return false
data[k] = semver.valid(val)
}
function validateStream (data, k, val) {
if (!(val instanceof Stream)) return false
data[k] = val
}
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
nopt.typeDefs.Octal = { type: Octal, validate: validateOctal }
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
nopt.invalidHandler = function (k, val, type, data) {
log.warn("invalid config", k + "=" + JSON.stringify(val))
if (Array.isArray(type)) {
if (type.indexOf(url) !== -1) type = url
else if (type.indexOf(path) !== -1) type = path
}
switch (type) {
case Octal:
log.warn("invalid config", "Must be octal number, starting with 0")
break
case url:
log.warn("invalid config", "Must be a full url with 'http://'")
function validateUmask (data, k, val) {
return umask.validate(data, k, val)
}
function validateSemver (data, k, val) {
if (!semver.valid(val)) return false
data[k] = semver.valid(val)
}
function validateStream (data, k, val) {
if (!(val instanceof Stream)) return false
data[k] = val
}
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
nopt.typeDefs.Umask = { type: Umask, validate: validateUmask }
nopt.invalidHandler = function (k, val, type) {
log.warn('invalid config', k + '=' + JSON.stringify(val))
if (Array.isArray(type)) {
if (type.indexOf(url) !== -1) type = url
else if (type.indexOf(path) !== -1) type = path
}
switch (type) {
case Umask:
log.warn('invalid config', 'Must be umask, octal number in range 0000..0777')
break
case url:
log.warn('invalid config', "Must be a full url with 'http://'")