Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function findHooksDir (dirname) {
var dir = findParentDir.sync(dirname, '.git')
if (dir) {
var gitDir = path.join(dir, '.git')
var stats = fs.lstatSync(gitDir)
if (stats.isFile()) {
// Expect following format
// git: pathToGit
gitDir = fs
.readFileSync(gitDir, 'utf-8')
.split(':')[1]
.trim()
return path.resolve(dir, gitDir, 'hooks')
}
PROJECT: () => {
let projectDirectory = findParentDir.sync(process.cwd(), DOT.PROJECT.PATH) || DOT.PROJECT.DIR;
return dotf(projectDirectory, DOT.PROJECT.NAME);
},
// See `login`: Stores { accessToken, refreshToken }
require: function (requirePath) {
try {
var path_1 = require("path");
// See if this is a 'node_modules' dependency:
var modulePath = findParentDir.sync(__dirname, path_1.join("node_modules", requirePath));
if (modulePath) {
requirePath = path_1.join(modulePath, "node_modules", requirePath);
}
return mod.require(requirePath);
}
catch (ex) {
// TODO: Log require error here
debugger; // tslint:disable-line no-debugger
}
},
};
var root = require('find-parent-dir').sync(__dirname, 'package.json');
var build = require(root + 'lib/build');
var chai = require('chai');
var expect = chai.expect;
describe('cli/build', function() {
it('should build without error', function() {
expect(function() {build();}).to.not.throw();
});
describe('custom builds', function(done) {
it('should build without errors when using a custom build', function() {
expect(function() {
build({'feature-detects': ['css/boxsizing']}, done);
}).to.not.throw();
.option('-h, --host ', 'Host to be used. Default is 127.0.0.1')
.option('-b, --bundle ', 'Create bundle and save it to bundleTo')
.action(function(swaggerFile, targetDir) {
swaggerFileValue = swaggerFile;
targetDirValue = targetDir;
})
.parse(process.argv);
if (typeof swaggerFileValue === 'undefined') {
console.error(` is required.\n${help}`);
process.exit(1);
}
if (typeof targetDirValue === 'undefined') {
try {
targetDirValue = findParentDir.sync(path.dirname(swaggerFileValue), path.basename(swaggerFileValue));
} catch (err) {
console.error(`Failed to resolve [targetDir]/${swaggerFileValue}.\n${help}`);
process.exit(1);
}
}
if (typeof program.port === 'undefined') {
program.port = 8000;
}
if (typeof program.host === 'undefined') {
program.host = "127.0.0.1";
}
if (typeof program.bundle === 'undefined') {
program.bundle = null;
module.exports = function getLayout(currentPath) {
const layoutDir = findParentDir.sync(currentPath, '_layout.js');
if (!layoutDir) {
return null;
}
const requirePath = path.resolve(layoutDir, '_layout.js');
const layout = require(requirePath);
delete require.cache[require.resolve(requirePath)];
return layout;
};
function resolvePath (root, parent, file) {
if (file.startsWith('/node_modules/')) {
return path.join(root, file)
} else if (file.startsWith('/')) {
const packageRoot = findParentDir.sync(parent, 'package.json')
if (packageRoot) {
return path.join(packageRoot, file)
} else {
return path.join(root, file)
}
} else {
return path.resolve(path.dirname(parent), file)
}
}