How to use the path-type.dirSync function in path-type

To help you get started, we’ve selected a few path-type examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alan-ai / alan-sdk-reactnative / testtools / node_modules / read-pkg / index.js View on Github external
module.exports.sync = (fp, opts) => {
	if (typeof fp !== 'string') {
		opts = fp;
		fp = '.';
	}

	opts = opts || {};
	fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;

	const x = loadJsonFile.sync(fp);

	if (opts.normalize !== false) {
		require('normalize-package-data')(x);
	}

	return x;
};
github sholladay / envy / index.js View on Github external
const assertIgnored = (filepath) => {
    const failMessage = `File must be ignored by git. Fix: echo '${path.basename(filepath)}' >> .gitignore`;
    let ignores;
    try {
        ignores = fs.readFileSync(path.join(filepath, '..', '.gitignore'), 'utf8');
    }
    catch (error) {
        if (error.code === 'ENOENT') {
            if (!pathType.dirSync(path.join(filepath, '..', '.git'))) {
                return;
            }
            throw new Error(failMessage);
        }
        throw error;
    }

    if (!ignores.split(/\r?\n/u).includes(path.basename(filepath))) {
        throw new Error(failMessage);
    }
};
github mapbox / batfish / src / node / validate-config.js View on Github external
function isExistingDirectory(value: *): boolean {
  if (!_.isString(value)) {
    return false;
  }
  return pathType.dirSync(value);
}
github hongmaoxiao / now / node_modules / read-pkg / index.js View on Github external
module.exports.sync = function (fp, opts) {
	if (typeof fp !== 'string') {
		opts = fp;
		fp = '.';
	}

	opts = opts || {};
	fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;

	var x = loadJsonFile.sync(fp);

	if (opts.normalize !== false) {
		normalizePackageData(x);
	}

	return x;
};
github sx1989827 / DOClever / Desktop / node_modules / webpack / node_modules / read-pkg / index.js View on Github external
module.exports.sync = (fp, opts) => {
	if (typeof fp !== 'string') {
		opts = fp;
		fp = '.';
	}

	opts = opts || {};
	fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;

	const x = loadJsonFile.sync(fp);

	if (opts.normalize !== false) {
		require('normalize-package-data')(x);
	}

	return x;
};
github xiaoqiang-zhao / cellar / web / articles / gulp / demo / node_modules / gulp-amd-optimizer / node_modules / gulp-util / node_modules / dateformat / node_modules / meow / node_modules / read-pkg-up / node_modules / read-pkg / index.js View on Github external
module.exports.sync = function (fp, opts) {
	if (typeof fp !== 'string') {
		opts = fp;
		fp = '.';
	}

	opts = opts || {};
	fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;

	var x = loadJsonFile.sync(fp);

	if (opts.normalize !== false) {
		normalizePackageData(x);
	}

	return x;
};

path-type

Check if a path is a file, directory, or symlink

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis