remote-jobs/bin/validate.js

51 lines
1.1 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
const { parseFromDirectory } = require( '../lib' );
const fs = require( 'fs' );
const path = require( 'path' );
// Accept an optional directory name where the content files live.
const contentPath = (
process.argv[ 2 ]
? path.resolve( process.argv[ 2 ] )
: path.join( __dirname, '..' )
);
// Parse the content from the directory.
const result = parseFromDirectory( contentPath );
// Report any errors.
const errorCount = result.errors ? result.errors.length : 0;
( result.errors || [] ).forEach( err => {
err.message.split( '\n' ).forEach( line => {
console.log( '%s: %s', err.filename, line );
} );
} );
// Count all profile headings, if requested.
if ( process.env.REPORT_PROFILE_HEADINGS ) {
console.log();
console.log(
'Profile headings by count (%d total profiles):',
result.profileFilenames.length
);
Object.keys( result.profileHeadingCounts ).forEach( heading => {
console.log(
'%s: %d',
heading,
result.profileHeadingCounts[ heading ]
);
} );
}
console.log();
console.log(
'%d problem%s detected',
errorCount,
( errorCount === 1 ? '' : 's' )
);
Add full profile search (#763) * Prevent duplicate company names * Fix output indentation * Search full profile content using lunr.js * Remove extra stop words This wasn't really working correctly - the stop word 'work' would leave instances of 'working' and 'works' in the index for example. * Change company name description from "Name" to "Company name" * Pre-process query: - Search for terms in AND mode, per https://lunrjs.com/guides/searching.html#term-presence - Discard non-alphanumeric characters from the search - Better handling of contractions and searching for stop words * Display search query and results in the console * Add special search token: _incomplete * Add a link to search for incomplete profiles * Revert "Add a link to search for incomplete profiles" This reverts commit f6384c90cb1790fdc7492b4e887127812db21f30. * Add link to search documentation * Improve search explanation appearance when it spans multiple lines * Fix searching for contractions Previously, searching for e.g. "don't" wasn't working correctly. After trimming the contraction, "do" is a stop word, so it should be ignored. * Improve "empty search" message * Prefer matches other than "company name" in search excerpts * Move inline scripts before external scripts This probably doesn't matter right now due to the way the scripts are currently structured, but it might matter one day and it's more logical this way. * Fix search engine index progress * Improve script indentation * I got 99 problems and they're all bots * Update script exit code When a Node.js error occurs the exit code is probably going to be 1, so we should use a different code. * Fix the tests * Update documentation This was wrong (out of date), but the correct version is obvious from reading the code. * Make download progress work in both Chrome and Firefox See https://stackoverflow.com/a/32799706
2020-05-06 06:42:21 +00:00
process.exitCode = ( errorCount > 0 ? 3 : 0 );