mirror of
https://github.com/h5bp/html5-boilerplate.git
synced 2026-01-09 14:48:02 -05:00
Features/eslint (#2037)
Fixes #1913 * Drops node 4 * update node engine to >=6 (#2035) * syncs changes to spacing across different editorconfigs * adds eslint with minimally invasive configuration- basically moving from 4 to 2 spaces.
This commit is contained in:
@@ -7,7 +7,7 @@ root = true
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
26
.eslintrc.js
Normal file
26
.eslintrc.js
Normal file
@@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"mocha": true
|
||||
},
|
||||
"plugins": ["mocha"],
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
2
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
};
|
||||
32
.jshintrc
32
.jshintrc
@@ -1,32 +0,0 @@
|
||||
{
|
||||
|
||||
// Enforcing options
|
||||
// http://jshint.com/docs/options/#enforcing-options
|
||||
|
||||
"bitwise": true,
|
||||
"eqeqeq": true,
|
||||
"forin": true,
|
||||
"latedef": true,
|
||||
"noarg": true,
|
||||
"nonbsp": true,
|
||||
"nonew": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// Relaxing options
|
||||
// http://jshint.com/docs/options/#relaxing-options
|
||||
|
||||
"esnext": true,
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// Environments
|
||||
// http://jshint.com/docs/options/#environments
|
||||
|
||||
"browser": true,
|
||||
"jquery": true,
|
||||
"node": true
|
||||
|
||||
}
|
||||
@@ -25,7 +25,6 @@ git:
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 4
|
||||
- 6
|
||||
- 8
|
||||
- 9
|
||||
|
||||
2
dist/.editorconfig
vendored
2
dist/.editorconfig
vendored
@@ -4,7 +4,7 @@ root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
32
dist/js/plugins.js
vendored
32
dist/js/plugins.js
vendored
@@ -1,24 +1,24 @@
|
||||
// Avoid `console` errors in browsers that lack a console.
|
||||
(function() {
|
||||
var method;
|
||||
var noop = function () {};
|
||||
var methods = [
|
||||
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
|
||||
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
|
||||
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
|
||||
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
|
||||
];
|
||||
var length = methods.length;
|
||||
var console = (window.console = window.console || {});
|
||||
var method;
|
||||
var noop = function () {};
|
||||
var methods = [
|
||||
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
|
||||
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
|
||||
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
|
||||
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
|
||||
];
|
||||
var length = methods.length;
|
||||
var console = (window.console = window.console || {});
|
||||
|
||||
while (length--) {
|
||||
method = methods[length];
|
||||
while (length--) {
|
||||
method = methods[length];
|
||||
|
||||
// Only stub undefined methods.
|
||||
if (!console[method]) {
|
||||
console[method] = noop;
|
||||
}
|
||||
// Only stub undefined methods.
|
||||
if (!console[method]) {
|
||||
console[method] = noop;
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
||||
// Place any jQuery/helper plugins in here.
|
||||
|
||||
@@ -28,149 +28,148 @@ const dirs = pkg['h5bp-configs'].directories;
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
gulp.task('archive:create_archive_dir', () => {
|
||||
fs.mkdirSync(path.resolve(dirs.archive), '0755');
|
||||
fs.mkdirSync(path.resolve(dirs.archive), '0755');
|
||||
});
|
||||
|
||||
gulp.task('archive:zip', (done) => {
|
||||
|
||||
const archiveName = path.resolve(dirs.archive, `${pkg.name}_v${pkg.version}.zip`);
|
||||
const zip = archiver('zip');
|
||||
const files = glob.sync('**/*.*', {
|
||||
'cwd': dirs.dist,
|
||||
'dot': true // include hidden files
|
||||
});
|
||||
const output = fs.createWriteStream(archiveName);
|
||||
const archiveName = path.resolve(dirs.archive, `${pkg.name}_v${pkg.version}.zip`);
|
||||
const zip = archiver('zip');
|
||||
const files = glob.sync('**/*.*', {
|
||||
'cwd': dirs.dist,
|
||||
'dot': true // include hidden files
|
||||
});
|
||||
const output = fs.createWriteStream(archiveName);
|
||||
|
||||
zip.on('error', (error) => {
|
||||
done();
|
||||
throw error;
|
||||
zip.on('error', (error) => {
|
||||
done();
|
||||
throw error;
|
||||
});
|
||||
|
||||
output.on('close', done);
|
||||
|
||||
files.forEach((file) => {
|
||||
|
||||
const filePath = path.resolve(dirs.dist, file);
|
||||
|
||||
// `zip.bulk` does not maintain the file
|
||||
// permissions, so we need to add files individually
|
||||
zip.append(fs.createReadStream(filePath), {
|
||||
'name': file,
|
||||
'mode': fs.statSync(filePath).mode
|
||||
});
|
||||
|
||||
output.on('close', done);
|
||||
});
|
||||
|
||||
files.forEach( (file) => {
|
||||
|
||||
const filePath = path.resolve(dirs.dist, file);
|
||||
|
||||
// `zip.bulk` does not maintain the file
|
||||
// permissions, so we need to add files individually
|
||||
zip.append(fs.createReadStream(filePath), {
|
||||
'name': file,
|
||||
'mode': fs.statSync(filePath).mode
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
zip.pipe(output);
|
||||
zip.finalize();
|
||||
zip.pipe(output);
|
||||
zip.finalize();
|
||||
|
||||
});
|
||||
|
||||
gulp.task('clean', (done) => {
|
||||
del([
|
||||
dirs.archive,
|
||||
dirs.dist
|
||||
]).then( () => {
|
||||
done();
|
||||
});
|
||||
del([
|
||||
dirs.archive,
|
||||
dirs.dist
|
||||
]).then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('copy', [
|
||||
'copy:.htaccess',
|
||||
'copy:index.html',
|
||||
'copy:jquery',
|
||||
'copy:license',
|
||||
'copy:main.css',
|
||||
'copy:misc',
|
||||
'copy:normalize'
|
||||
'copy:.htaccess',
|
||||
'copy:index.html',
|
||||
'copy:jquery',
|
||||
'copy:license',
|
||||
'copy:main.css',
|
||||
'copy:misc',
|
||||
'copy:normalize'
|
||||
]);
|
||||
|
||||
gulp.task('copy:.htaccess', () =>
|
||||
gulp.src('node_modules/apache-server-configs/dist/.htaccess')
|
||||
.pipe(plugins().replace(/# ErrorDocument/g, 'ErrorDocument'))
|
||||
.pipe(gulp.dest(dirs.dist))
|
||||
gulp.src('node_modules/apache-server-configs/dist/.htaccess')
|
||||
.pipe(plugins().replace(/# ErrorDocument/g, 'ErrorDocument'))
|
||||
.pipe(gulp.dest(dirs.dist))
|
||||
);
|
||||
|
||||
gulp.task('copy:index.html', () => {
|
||||
const hash = ssri.fromData(
|
||||
fs.readFileSync('node_modules/jquery/dist/jquery.min.js'),
|
||||
{ algorithms: ['sha256'] }
|
||||
);
|
||||
let version = pkg.devDependencies.jquery;
|
||||
let modernizrVersion = pkg.devDependencies.modernizr;
|
||||
const hash = ssri.fromData(
|
||||
fs.readFileSync('node_modules/jquery/dist/jquery.min.js'),
|
||||
{algorithms: ['sha256']}
|
||||
);
|
||||
let version = pkg.devDependencies.jquery;
|
||||
let modernizrVersion = pkg.devDependencies.modernizr;
|
||||
|
||||
gulp.src(`${dirs.src}/index.html`)
|
||||
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
|
||||
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
|
||||
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash.toString()))
|
||||
.pipe(gulp.dest(dirs.dist));
|
||||
gulp.src(`${dirs.src}/index.html`)
|
||||
.pipe(plugins().replace(/{{JQUERY_VERSION}}/g, version))
|
||||
.pipe(plugins().replace(/{{MODERNIZR_VERSION}}/g, modernizrVersion))
|
||||
.pipe(plugins().replace(/{{JQUERY_SRI_HASH}}/g, hash.toString()))
|
||||
.pipe(gulp.dest(dirs.dist));
|
||||
});
|
||||
|
||||
gulp.task('copy:jquery', () =>
|
||||
gulp.src(['node_modules/jquery/dist/jquery.min.js'])
|
||||
.pipe(plugins().rename(`jquery-${pkg.devDependencies.jquery}.min.js`))
|
||||
.pipe(gulp.dest(`${dirs.dist}/js/vendor`))
|
||||
gulp.src(['node_modules/jquery/dist/jquery.min.js'])
|
||||
.pipe(plugins().rename(`jquery-${pkg.devDependencies.jquery}.min.js`))
|
||||
.pipe(gulp.dest(`${dirs.dist}/js/vendor`))
|
||||
);
|
||||
|
||||
gulp.task('copy:license', () =>
|
||||
gulp.src('LICENSE.txt')
|
||||
.pipe(gulp.dest(dirs.dist))
|
||||
gulp.src('LICENSE.txt')
|
||||
.pipe(gulp.dest(dirs.dist))
|
||||
);
|
||||
|
||||
gulp.task('copy:main.css', () => {
|
||||
|
||||
const banner = `/*! HTML5 Boilerplate v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */\n\n`;
|
||||
const banner = `/*! HTML5 Boilerplate v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */\n\n`;
|
||||
|
||||
gulp.src(`${dirs.src}/css/main.css`)
|
||||
.pipe(plugins().header(banner))
|
||||
.pipe(plugins().autoprefixer({
|
||||
browsers: ['last 2 versions', 'ie >= 9', '> 1%'],
|
||||
cascade: false
|
||||
}))
|
||||
.pipe(gulp.dest(`${dirs.dist}/css`));
|
||||
gulp.src(`${dirs.src}/css/main.css`)
|
||||
.pipe(plugins().header(banner))
|
||||
.pipe(plugins().autoprefixer({
|
||||
browsers: ['last 2 versions', 'ie >= 9', '> 1%'],
|
||||
cascade: false
|
||||
}))
|
||||
.pipe(gulp.dest(`${dirs.dist}/css`));
|
||||
});
|
||||
|
||||
gulp.task('copy:misc', () =>
|
||||
gulp.src([
|
||||
gulp.src([
|
||||
|
||||
// Copy all files
|
||||
`${dirs.src}/**/*`,
|
||||
// Copy all files
|
||||
`${dirs.src}/**/*`,
|
||||
|
||||
// Exclude the following files
|
||||
// (other tasks will handle the copying of these files)
|
||||
`!${dirs.src}/css/main.css`,
|
||||
`!${dirs.src}/index.html`
|
||||
// Exclude the following files
|
||||
// (other tasks will handle the copying of these files)
|
||||
`!${dirs.src}/css/main.css`,
|
||||
`!${dirs.src}/index.html`
|
||||
|
||||
], {
|
||||
], {
|
||||
|
||||
// Include hidden files by default
|
||||
dot: true
|
||||
// Include hidden files by default
|
||||
dot: true
|
||||
|
||||
}).pipe(gulp.dest(dirs.dist))
|
||||
}).pipe(gulp.dest(dirs.dist))
|
||||
);
|
||||
|
||||
gulp.task('copy:normalize', () =>
|
||||
gulp.src('node_modules/normalize.css/normalize.css')
|
||||
.pipe(gulp.dest(`${dirs.dist}/css`))
|
||||
gulp.src('node_modules/normalize.css/normalize.css')
|
||||
.pipe(gulp.dest(`${dirs.dist}/css`))
|
||||
);
|
||||
|
||||
gulp.task( 'modernizr', (done) =>{
|
||||
gulp.task('modernizr', (done) =>{
|
||||
|
||||
modernizr.build(modernizrConfig, (code) => {
|
||||
fs.writeFile(`${dirs.dist}/js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`, code, done);
|
||||
});
|
||||
modernizr.build(modernizrConfig, (code) => {
|
||||
fs.writeFile(`${dirs.dist}/js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`, code, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
gulp.task('lint:js', () =>
|
||||
gulp.src([
|
||||
'gulpfile.js',
|
||||
`${dirs.src}/js/*.js`,
|
||||
`${dirs.test}/*.js`
|
||||
]).pipe(plugins().jscs())
|
||||
.pipe(plugins().jshint())
|
||||
.pipe(plugins().jshint.reporter('jshint-stylish'))
|
||||
.pipe(plugins().jshint.reporter('fail'))
|
||||
gulp.src([
|
||||
'gulpfile.js',
|
||||
`${dirs.src}/js/*.js`,
|
||||
`${dirs.test}/*.js`
|
||||
]).pipe(plugins().jscs())
|
||||
.pipe(plugins().eslint())
|
||||
.pipe(plugins().eslint.failOnError())
|
||||
);
|
||||
|
||||
|
||||
@@ -179,17 +178,17 @@ gulp.task('lint:js', () =>
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
gulp.task('archive', (done) => {
|
||||
runSequence(
|
||||
'build',
|
||||
'archive:create_archive_dir',
|
||||
'archive:zip',
|
||||
runSequence(
|
||||
'build',
|
||||
'archive:create_archive_dir',
|
||||
'archive:zip',
|
||||
done);
|
||||
});
|
||||
|
||||
gulp.task('build', (done) => {
|
||||
runSequence(
|
||||
['clean', 'lint:js'],
|
||||
'copy', 'modernizr',
|
||||
runSequence(
|
||||
['clean', 'lint:js'],
|
||||
'copy', 'modernizr',
|
||||
done);
|
||||
});
|
||||
|
||||
|
||||
7075
package-lock.json
generated
Normal file
7075
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -7,18 +7,19 @@
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-register": "^6.26.0",
|
||||
"del": "^3.0.0",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-recommended": "^2.0.0",
|
||||
"eslint-plugin-mocha": "^5.0.0",
|
||||
"glob": "^7.1.2",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-autoprefixer": "^5.0.0",
|
||||
"gulp-eslint": "^4.0.2",
|
||||
"gulp-header": "^2.0.5",
|
||||
"gulp-jscs": "^4.1.0",
|
||||
"gulp-jshint": "^2.1.0",
|
||||
"gulp-load-plugins": "^1.5.0",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-replace": "^0.6.1",
|
||||
"jquery": "3.3.1",
|
||||
"jshint": "^2.9.5",
|
||||
"jshint-stylish": "^2.2.1",
|
||||
"mocha": "^5.0.5",
|
||||
"modernizr": "3.6.0",
|
||||
"normalize.css": "8.0.0",
|
||||
@@ -28,7 +29,7 @@
|
||||
"travis-after-all": "^1.4.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4",
|
||||
"node": ">=6",
|
||||
"npm": ">=3"
|
||||
},
|
||||
"babel": {
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
// Avoid `console` errors in browsers that lack a console.
|
||||
(function() {
|
||||
var method;
|
||||
var noop = function () {};
|
||||
var methods = [
|
||||
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
|
||||
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
|
||||
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
|
||||
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
|
||||
];
|
||||
var length = methods.length;
|
||||
var console = (window.console = window.console || {});
|
||||
var method;
|
||||
var noop = function () {};
|
||||
var methods = [
|
||||
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
|
||||
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
|
||||
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
|
||||
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
|
||||
];
|
||||
var length = methods.length;
|
||||
var console = (window.console = window.console || {});
|
||||
|
||||
while (length--) {
|
||||
method = methods[length];
|
||||
while (length--) {
|
||||
method = methods[length];
|
||||
|
||||
// Only stub undefined methods.
|
||||
if (!console[method]) {
|
||||
console[method] = noop;
|
||||
}
|
||||
// Only stub undefined methods.
|
||||
if (!console[method]) {
|
||||
console[method] = noop;
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
||||
// Place any jQuery/helper plugins in here.
|
||||
|
||||
@@ -12,36 +12,36 @@ const dirs = pkg['h5bp-configs'].directories;
|
||||
|
||||
function checkString(file, string, done) {
|
||||
|
||||
let character = '';
|
||||
let matchFound = false;
|
||||
let matchedPositions = 0;
|
||||
const readStream = fs.createReadStream(file, { 'encoding': 'utf8' });
|
||||
let character = '';
|
||||
let matchFound = false;
|
||||
let matchedPositions = 0;
|
||||
const readStream = fs.createReadStream(file, {'encoding': 'utf8'});
|
||||
|
||||
readStream.on('close', done);
|
||||
readStream.on('error', done);
|
||||
readStream.on('readable', function () {
|
||||
readStream.on('close', done);
|
||||
readStream.on('error', done);
|
||||
readStream.on('readable', function () {
|
||||
|
||||
// Read file until the string is found
|
||||
// or the whole file has been read
|
||||
while (matchFound !== true &&
|
||||
// Read file until the string is found
|
||||
// or the whole file has been read
|
||||
while (matchFound !== true &&
|
||||
(character = readStream.read(1)) !== null) {
|
||||
|
||||
if (character === string.charAt(matchedPositions)) {
|
||||
matchedPositions += 1;
|
||||
} else {
|
||||
matchedPositions = 0;
|
||||
}
|
||||
if (character === string.charAt(matchedPositions)) {
|
||||
matchedPositions += 1;
|
||||
} else {
|
||||
matchedPositions = 0;
|
||||
}
|
||||
|
||||
if (matchedPositions === string.length) {
|
||||
matchFound = true;
|
||||
}
|
||||
if (matchedPositions === string.length) {
|
||||
matchFound = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(true, matchFound);
|
||||
this.close();
|
||||
assert.equal(true, matchFound);
|
||||
this.close();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -49,37 +49,37 @@ function checkString(file, string, done) {
|
||||
|
||||
function runTests() {
|
||||
|
||||
const dir = dirs.dist;
|
||||
const dir = dirs.dist;
|
||||
|
||||
describe(`Test if the files from the "${dir}" directory have the expected content`, () => {
|
||||
|
||||
it('".htaccess" should have the "ErrorDocument..." line uncommented', (done) => {
|
||||
const string = '\n\nErrorDocument 404 /404.html\n\n';
|
||||
checkString(path.resolve(dir, '.htaccess'), string, done);
|
||||
});
|
||||
|
||||
it('"index.html" should contain the correct jQuery version in the CDN URL', (done) => {
|
||||
const string = `code.jquery.com/jquery-${pkg.devDependencies.jquery}.min.js`;
|
||||
checkString(path.resolve(dir, 'index.html'), string, done);
|
||||
});
|
||||
|
||||
it('"index.html" should contain the correct jQuery version in the local URL', (done) => {
|
||||
const string = `js/vendor/jquery-${pkg.devDependencies.jquery}.min.js`;
|
||||
checkString(path.resolve(dir, 'index.html'), string, done);
|
||||
});
|
||||
|
||||
it('"index.html" should contain the correct Modernizr version in the local URL', (done) => {
|
||||
const string = `js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`;
|
||||
checkString(path.resolve(dir, 'index.html'), string, done);
|
||||
});
|
||||
|
||||
it('"main.css" should contain a custom banner', function (done) {
|
||||
const string = `/*! HTML5 Boilerplate v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */\n\n/*\n`;
|
||||
checkString(path.resolve(dir, 'css/main.css'), string, done);
|
||||
});
|
||||
describe(`Test if the files from the "${dir}" directory have the expected content`, () => {
|
||||
|
||||
it('".htaccess" should have the "ErrorDocument..." line uncommented', (done) => {
|
||||
const string = '\n\nErrorDocument 404 /404.html\n\n';
|
||||
checkString(path.resolve(dir, '.htaccess'), string, done);
|
||||
});
|
||||
|
||||
it('"index.html" should contain the correct jQuery version in the CDN URL', (done) => {
|
||||
const string = `code.jquery.com/jquery-${pkg.devDependencies.jquery}.min.js`;
|
||||
checkString(path.resolve(dir, 'index.html'), string, done);
|
||||
});
|
||||
|
||||
it('"index.html" should contain the correct jQuery version in the local URL', (done) => {
|
||||
const string = `js/vendor/jquery-${pkg.devDependencies.jquery}.min.js`;
|
||||
checkString(path.resolve(dir, 'index.html'), string, done);
|
||||
});
|
||||
|
||||
it('"index.html" should contain the correct Modernizr version in the local URL', (done) => {
|
||||
const string = `js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`;
|
||||
checkString(path.resolve(dir, 'index.html'), string, done);
|
||||
});
|
||||
|
||||
it('"main.css" should contain a custom banner', function (done) {
|
||||
const string = `/*! HTML5 Boilerplate v${pkg.version} | ${pkg.license} License | ${pkg.homepage} */\n\n/*\n`;
|
||||
checkString(path.resolve(dir, 'css/main.css'), string, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
runTests();
|
||||
|
||||
@@ -10,55 +10,55 @@ import pkg from './../package.json';
|
||||
const dirs = pkg['h5bp-configs'].directories;
|
||||
|
||||
const expectedFilesInArchiveDir = [
|
||||
`${pkg.name}_v${pkg.version}.zip`
|
||||
`${pkg.name}_v${pkg.version}.zip`
|
||||
];
|
||||
|
||||
const expectedFilesInDistDir = [
|
||||
|
||||
'.editorconfig',
|
||||
'.gitattributes',
|
||||
'.gitignore',
|
||||
'.htaccess',
|
||||
'404.html',
|
||||
'browserconfig.xml',
|
||||
'.editorconfig',
|
||||
'.gitattributes',
|
||||
'.gitignore',
|
||||
'.htaccess',
|
||||
'404.html',
|
||||
'browserconfig.xml',
|
||||
|
||||
'css/', // for directories, a `/` character
|
||||
// should be included at the end
|
||||
'css/main.css',
|
||||
'css/normalize.css',
|
||||
'css/', // for directories, a `/` character
|
||||
// should be included at the end
|
||||
'css/main.css',
|
||||
'css/normalize.css',
|
||||
|
||||
'doc/',
|
||||
'doc/TOC.md',
|
||||
'doc/css.md',
|
||||
'doc/extend.md',
|
||||
'doc/faq.md',
|
||||
'doc/html.md',
|
||||
'doc/js.md',
|
||||
'doc/misc.md',
|
||||
'doc/usage.md',
|
||||
'doc/',
|
||||
'doc/TOC.md',
|
||||
'doc/css.md',
|
||||
'doc/extend.md',
|
||||
'doc/faq.md',
|
||||
'doc/html.md',
|
||||
'doc/js.md',
|
||||
'doc/misc.md',
|
||||
'doc/usage.md',
|
||||
|
||||
'favicon.ico',
|
||||
'humans.txt',
|
||||
'favicon.ico',
|
||||
'humans.txt',
|
||||
|
||||
'icon.png',
|
||||
'icon.png',
|
||||
|
||||
'img/',
|
||||
'img/.gitignore',
|
||||
'img/',
|
||||
'img/.gitignore',
|
||||
|
||||
'index.html',
|
||||
'index.html',
|
||||
|
||||
'js/',
|
||||
'js/main.js',
|
||||
'js/plugins.js',
|
||||
'js/vendor/',
|
||||
`js/vendor/jquery-${pkg.devDependencies.jquery}.min.js`,
|
||||
`js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`,
|
||||
'js/',
|
||||
'js/main.js',
|
||||
'js/plugins.js',
|
||||
'js/vendor/',
|
||||
`js/vendor/jquery-${pkg.devDependencies.jquery}.min.js`,
|
||||
`js/vendor/modernizr-${pkg.devDependencies.modernizr}.min.js`,
|
||||
|
||||
'LICENSE.txt',
|
||||
'robots.txt',
|
||||
'site.webmanifest',
|
||||
'tile-wide.png',
|
||||
'tile.png'
|
||||
'LICENSE.txt',
|
||||
'robots.txt',
|
||||
'site.webmanifest',
|
||||
'tile-wide.png',
|
||||
'tile.png'
|
||||
|
||||
];
|
||||
|
||||
@@ -66,51 +66,51 @@ const expectedFilesInDistDir = [
|
||||
|
||||
function checkFiles(directory, expectedFiles) {
|
||||
|
||||
// Get the list of files from the specified directory
|
||||
const files = glob.sync('**/*', {
|
||||
'cwd': directory,
|
||||
'dot': true, // include hidden files
|
||||
'mark': true // add a `/` character to directory matches
|
||||
});
|
||||
// Get the list of files from the specified directory
|
||||
const files = glob.sync('**/*', {
|
||||
'cwd': directory,
|
||||
'dot': true, // include hidden files
|
||||
'mark': true // add a `/` character to directory matches
|
||||
});
|
||||
|
||||
// Check if all expected files are present in the
|
||||
// specified directory, and are of the expected type
|
||||
expectedFiles.forEach( (file) => {
|
||||
expectedFiles.forEach((file) => {
|
||||
|
||||
let ok = false;
|
||||
const expectedFileType = (file.slice(-1) !== '/' ? 'regular file' : 'directory');
|
||||
let ok = false;
|
||||
const expectedFileType = (file.slice(-1) !== '/' ? 'regular file' : 'directory');
|
||||
|
||||
// If file exists
|
||||
if (files.indexOf(file) !== -1) {
|
||||
// If file exists
|
||||
if (files.indexOf(file) !== -1) {
|
||||
|
||||
// Check if the file is of the correct type
|
||||
if (file.slice(-1) !== '/') {
|
||||
// Check if the file is really a regular file
|
||||
ok = fs.statSync(path.resolve(directory, file)).isFile();
|
||||
} else {
|
||||
// Check if the file is a directory
|
||||
// (Since glob adds the `/` character to directory matches,
|
||||
// we can simply check if the `/` character is present)
|
||||
ok = (files[files.indexOf(file)].slice(-1) === '/');
|
||||
}
|
||||
// Check if the file is of the correct type
|
||||
if (file.slice(-1) !== '/') {
|
||||
// Check if the file is really a regular file
|
||||
ok = fs.statSync(path.resolve(directory, file)).isFile();
|
||||
} else {
|
||||
// Check if the file is a directory
|
||||
// (Since glob adds the `/` character to directory matches,
|
||||
// we can simply check if the `/` character is present)
|
||||
ok = (files[files.indexOf(file)].slice(-1) === '/');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
it(`"${file}" should be present and it should be a ${expectedFileType}`, () =>{
|
||||
assert.equal(true, ok);
|
||||
});
|
||||
}
|
||||
|
||||
it(`"${file}" should be present and it should be a ${expectedFileType}`, () =>{
|
||||
assert.equal(true, ok);
|
||||
});
|
||||
|
||||
// List all files that should be NOT
|
||||
// be present in the specified directory
|
||||
(files.filter( (file) => {
|
||||
return expectedFiles.indexOf(file) === -1;
|
||||
})).forEach( (file) => {
|
||||
it(`"${file}" should NOT be present`, () => {
|
||||
assert(false);
|
||||
});
|
||||
});
|
||||
|
||||
// List all files that should be NOT
|
||||
// be present in the specified directory
|
||||
(files.filter((file) => {
|
||||
return expectedFiles.indexOf(file) === -1;
|
||||
})).forEach((file) => {
|
||||
it(`"${file}" should NOT be present`, () => {
|
||||
assert(false);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -118,18 +118,18 @@ function checkFiles(directory, expectedFiles) {
|
||||
|
||||
function runTests() {
|
||||
|
||||
describe('Test if all the expected files, and only them, are present in the build directories', () => {
|
||||
|
||||
describe(dirs.archive, () => {
|
||||
checkFiles(dirs.archive, expectedFilesInArchiveDir);
|
||||
});
|
||||
|
||||
describe(dirs.dist, () => {
|
||||
checkFiles(dirs.dist, expectedFilesInDistDir);
|
||||
});
|
||||
describe('Test if all the expected files, and only them, are present in the build directories', () => {
|
||||
|
||||
describe(dirs.archive, () => {
|
||||
checkFiles(dirs.archive, expectedFilesInArchiveDir);
|
||||
});
|
||||
|
||||
describe(dirs.dist, () => {
|
||||
checkFiles(dirs.dist, expectedFilesInDistDir);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
runTests();
|
||||
|
||||
Reference in New Issue
Block a user