Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Refactor to support a test to require and es-checking library files #7

Merged
merged 4 commits into from
Oct 19, 2020

Conversation

brandonocasey
Copy link
Contributor

No description provided.

@@ -17,7 +17,8 @@
"dependencies": {
"colorette": "^1.1.0",
"es-check": "^5.0.0",
"pkg-can-install": "^1.0.4",
"exit-hook": "^2.2.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependency updates.


const run = function(cwd, pkg) {
return Promise.resolve().then(function() {
if (pkg.main) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test if we can require a package or not (but only if it has a main file)

@@ -21,7 +21,8 @@ const printHelp = function() {
console.log(' -V, --verbose Print all results, even successful ones.');
console.log(' -q, --quiet Don\'t print anything.');
console.log(' -d, --dir [dir] Run in this project directory, defaults to cwd.');
console.log(' --skip-es-check Do not run es check on dist, for projects with no dist.');
console.log(' --skip-es-check skip the syntax check, still here for backwards compatablity');
console.log(` --skip-[name] skip a test that you do not want to run. ${testNames.join(', ')}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option replaces --skip-es-check and supports any of the tests that we run. I am keeping --skip-es-check around to keep this fairly backwards compatible.

const promiseSpawn = require('./promise-spawn.js');
const exitHook = require('exit-hook');

const run = function(cwd) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic used to live in the main verify function, but it just made things confusing.

const text = 'Dist files have the correct js syntax';
const cjsFields = ['bin', 'main', 'browser'];
const esFields = ['es2015', 'module'];
const getFieldFiles = function(cwd, pkg, fields) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

es check any files in package.json, and files in ./es, ./cjs ./dist/*.js and ./dist/lang/*.js

const pkgCanInstall = require('./pkg-can-install.js');
const canRequire = require('./can-require');

const tests = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we ever find that we need to add more tests in the future it will be easy now. Furthermore tests now have names that make sense, rather than being named after binaries.

Copy link
Member

@misteroneill misteroneill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look too deeply because of the number of changes, but seems good.

@brandonocasey brandonocasey merged commit 71e2ea1 into master Oct 19, 2020
@brandonocasey brandonocasey deleted the feat/library branch October 19, 2020 20:12
brandonocasey added a commit that referenced this pull request Oct 19, 2020
…iles (#7)

BREAKING CHANGE: Many new files are checked for syntax. Index file returns a new promise format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants