mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-17 15:53:38 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
72
node_modules/cosmiconfig/lib/loadDefinedFile.js
generated
vendored
Normal file
72
node_modules/cosmiconfig/lib/loadDefinedFile.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('graceful-fs');
|
||||
var Promise = require('pinkie-promise');
|
||||
var yaml = require('js-yaml');
|
||||
var parseJson = require('parse-json');
|
||||
var requireFromString = require('require-from-string');
|
||||
|
||||
module.exports = function(filepath, expectedFormat) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.readFile(filepath, 'utf8', function(fileError, content) {
|
||||
if (fileError) return reject(fileError);
|
||||
resolve(content);
|
||||
});
|
||||
}).then(function(content) {
|
||||
var parsedConfig = (function() {
|
||||
switch (expectedFormat) {
|
||||
case 'json':
|
||||
return parseJson(content, filepath);
|
||||
case 'yaml':
|
||||
return yaml.safeLoad(content, {
|
||||
filename: filepath,
|
||||
});
|
||||
case 'js':
|
||||
return requireFromString(content, filepath);
|
||||
default:
|
||||
return tryAllParsing(content, filepath);
|
||||
}
|
||||
})();
|
||||
|
||||
if (!parsedConfig) {
|
||||
throw new Error(
|
||||
'Failed to parse "' + filepath + '" as JSON, JS, or YAML.'
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
config: parsedConfig,
|
||||
filepath: filepath,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
function tryAllParsing(content, filepath) {
|
||||
return tryYaml(content, filepath, function() {
|
||||
return tryRequire(content, filepath, function() {
|
||||
return null;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function tryYaml(content, filepath, cb) {
|
||||
try {
|
||||
var result = yaml.safeLoad(content, {
|
||||
filename: filepath,
|
||||
});
|
||||
if (typeof result === 'string') {
|
||||
return cb();
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
return cb();
|
||||
}
|
||||
}
|
||||
|
||||
function tryRequire(content, filepath, cb) {
|
||||
try {
|
||||
return requireFromString(content, filepath);
|
||||
} catch (e) {
|
||||
return cb();
|
||||
}
|
||||
}
|
||||
24
node_modules/cosmiconfig/lib/loadJs.js
generated
vendored
Normal file
24
node_modules/cosmiconfig/lib/loadJs.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('graceful-fs');
|
||||
var Promise = require('pinkie-promise');
|
||||
var requireFromString = require('require-from-string');
|
||||
|
||||
module.exports = function(filepath) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.readFile(filepath, 'utf8', function(fileError, content) {
|
||||
if (fileError) {
|
||||
if (fileError.code === 'ENOENT') return resolve(null);
|
||||
return reject(fileError);
|
||||
}
|
||||
resolve(content);
|
||||
});
|
||||
}).then(function(content) {
|
||||
if (!content) return null;
|
||||
|
||||
return {
|
||||
config: requireFromString(content, filepath),
|
||||
filepath: filepath,
|
||||
};
|
||||
});
|
||||
};
|
||||
29
node_modules/cosmiconfig/lib/loadPackageProp.js
generated
vendored
Normal file
29
node_modules/cosmiconfig/lib/loadPackageProp.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('graceful-fs');
|
||||
var Promise = require('pinkie-promise');
|
||||
var parseJson = require('parse-json');
|
||||
|
||||
module.exports = function(packageDir, packageProp) {
|
||||
var packagePath = path.join(packageDir, 'package.json');
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.readFile(packagePath, 'utf8', function(fileError, content) {
|
||||
if (fileError) {
|
||||
if (fileError.code === 'ENOENT') return resolve(null);
|
||||
return reject(fileError);
|
||||
}
|
||||
resolve(content);
|
||||
});
|
||||
}).then(function(content) {
|
||||
if (!content) return null;
|
||||
var parsedContent = parseJson(content, packagePath);
|
||||
var packagePropValue = parsedContent[packageProp];
|
||||
if (!packagePropValue) return null;
|
||||
|
||||
return {
|
||||
config: packagePropValue,
|
||||
filepath: packagePath,
|
||||
};
|
||||
});
|
||||
};
|
||||
92
node_modules/cosmiconfig/lib/loadRc.js
generated
vendored
Normal file
92
node_modules/cosmiconfig/lib/loadRc.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('graceful-fs');
|
||||
var Promise = require('pinkie-promise');
|
||||
var yaml = require('js-yaml');
|
||||
var parseJson = require('parse-json');
|
||||
var requireFromString = require('require-from-string');
|
||||
|
||||
module.exports = function(filepath, options) {
|
||||
return loadExtensionlessRc().then(function(result) {
|
||||
if (result) return result;
|
||||
if (options.extensions) return loadRcWithExtensions();
|
||||
return null;
|
||||
});
|
||||
|
||||
function loadExtensionlessRc() {
|
||||
return readRcFile().then(function(content) {
|
||||
if (!content) return null;
|
||||
|
||||
var pasedConfig = (options.strictJson)
|
||||
? parseJson(content, filepath)
|
||||
: yaml.safeLoad(content, {
|
||||
filename: filepath,
|
||||
});
|
||||
return {
|
||||
config: pasedConfig,
|
||||
filepath: filepath,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function loadRcWithExtensions() {
|
||||
return readRcFile('json').then(function(content) {
|
||||
if (content) {
|
||||
var successFilepath = filepath + '.json';
|
||||
return {
|
||||
config: parseJson(content, successFilepath),
|
||||
filepath: successFilepath,
|
||||
};
|
||||
}
|
||||
// If not content was found in the file with extension,
|
||||
// try the next possible extension
|
||||
return readRcFile('yaml');
|
||||
}).then(function(content) {
|
||||
if (content) {
|
||||
// If the previous check returned an object with a config
|
||||
// property, then it succeeded and this step can be skipped
|
||||
if (content.config) return content;
|
||||
// If it just returned a string, then *this* check succeeded
|
||||
var successFilepath = filepath + '.yaml';
|
||||
return {
|
||||
config: yaml.safeLoad(content, { filename: successFilepath }),
|
||||
filepath: successFilepath,
|
||||
};
|
||||
}
|
||||
return readRcFile('yml');
|
||||
}).then(function(content) {
|
||||
if (content) {
|
||||
if (content.config) return content;
|
||||
var successFilepath = filepath + '.yml';
|
||||
return {
|
||||
config: yaml.safeLoad(content, { filename: successFilepath }),
|
||||
filepath: successFilepath,
|
||||
};
|
||||
}
|
||||
return readRcFile('js');
|
||||
}).then(function(content) {
|
||||
if (content) {
|
||||
if (content.config) return content;
|
||||
var successFilepath = filepath + '.js';
|
||||
return {
|
||||
config: requireFromString(content, successFilepath),
|
||||
filepath: successFilepath,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
function readRcFile(extension) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var filepathWithExtension = (extension) ? filepath + '.' + extension : filepath;
|
||||
fs.readFile(filepathWithExtension, 'utf8', function(fileError, content) {
|
||||
if (fileError) {
|
||||
if (fileError.code === 'ENOENT') return resolve(null);
|
||||
return reject(fileError);
|
||||
}
|
||||
resolve(content);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user