Skip to content

Commit

Permalink
chore: update lint scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
benjycui committed Apr 14, 2016
1 parent 9d95313 commit 7a6485d
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 36 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@
"deploy": "rm -rf node_modules && node scripts/install.js && npm run just-deploy",
"just-deploy": "npm run site && node scripts/deploy.js",
"lint": "npm run srclint && npm run demolint && npm run lesshint",
"srclint": "ANTD=SRC eslint components test site index.js --ext '.js,.jsx'",
"srclint": "ANTD=SRC eslint components test site scripts ./*.js --ext '.js,.jsx'",
"demolint": "ANTD=DEMO eslint components/*/demo/*.md --ext '.md'",
"lesshint": "lesshint style/ -e 'style/+(core|mixins)/+(base|iconfont|normalize|layouts|compatibility|grid).less'",
"eslint-fix": "eslint --fix components test site index.js --ext '.js,.jsx' && eslint-tinker ./components/*/demo/*.md",
"eslint-fix": "eslint --fix components test site scripts ./*.js --ext '.js,.jsx' && eslint-tinker ./components/*/demo/*.md",
"test": "npm run lint && atool-build && npm run jest",
"jest": "jest",
"pub": "sh ./scripts/publish.sh",
Expand Down
3 changes: 0 additions & 3 deletions scripts/build-common.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict';

const fs = require('fs');
const path = require('path');
const R = require('ramda');
const utils = require('./utils');

module.exports = function buildCommon(dirs, outputFile) {
Expand Down
6 changes: 2 additions & 4 deletions scripts/build-demos-list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const fs = require('fs');
const path = require('path');
const R = require('ramda');
Expand All @@ -23,10 +21,10 @@ module.exports = function buildDemosList(dirs, outputPath) {
Object.keys(groupedDemos).forEach((key) => {
content += `\n '${key}': [`;
groupedDemos[key].forEach((fileName) => {
const requirePath = path.relative(path.dirname(outputPath), fileName)
const requirePath = path.relative(path.dirname(outputPath), fileName);
content += `\n require('${requirePath}'),`;
});
content += '\n ],'
content += '\n ],';
});
content += '\n};\n';

Expand Down
2 changes: 0 additions & 2 deletions scripts/build-website.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#! /usr/bin/env node

'use strict';

// Ensure that data directory exist.
require('mkdirp').sync('./_data');

Expand Down
8 changes: 4 additions & 4 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var ghPages = require('gh-pages');
var path = require('path');
const ghPages = require('gh-pages');
const path = require('path');
ghPages.publish(path.join(process.cwd(), '_site'), {
depth: 1,
logger: function (message) {
logger(message) {
console.log(message);
}
}, function (err) {
}, (err) => {
if (err) {
throw err;
}
Expand Down
18 changes: 9 additions & 9 deletions scripts/install.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
function runCmd(cmd, args, fn) {
args = args || [];
var runner = require('child_process').spawn(cmd, args, {
const runner = require('child_process').spawn(cmd, args, {
// keep color
stdio: "inherit"
stdio: 'inherit'
});
runner.on('close', function (code) {
runner.on('close', (code) => {
if (fn) {
fn(code);
}
});
}

runCmd('which', ['tnpm'], function (code) {
var npm = 'npm';
runCmd('which', ['tnpm'], (code) => {
let npm = 'npm';
if (!code) {
npm = 'tnpm';
}
console.log(npm + ' installing');
runCmd(npm, ['install'], function () {
console.log(npm + ' install end');
console.log(`${npm} installing`);
runCmd(npm, ['install'], () => {
console.log(`${npm} install end`);
});
});
});
12 changes: 6 additions & 6 deletions scripts/prenpm.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var fs = require('fs');
var cwd = process.cwd();
var path = require('path');
var originalIndex = fs.readFileSync(path.join(cwd, 'lib/index.js'), 'utf-8');
var newIndex = originalIndex
const fs = require('fs');
const cwd = process.cwd();
const path = require('path');
const originalIndex = fs.readFileSync(path.join(cwd, 'lib/index.js'), 'utf-8');
const newIndex = originalIndex
.replace(/\/components\//g, '/');
fs.writeFileSync(path.join(cwd, 'lib/index.js'), newIndex, 'utf-8');
var antdCss = path.join(cwd, 'dist/antd.css');
const antdCss = path.join(cwd, 'dist/antd.css');
fs.createReadStream(antdCss)
.pipe(fs.createWriteStream(path.join(cwd, 'lib/index.css')));
console.log('prenpm done');
7 changes: 4 additions & 3 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const fs = require('fs');
const path = require('path');
const R = require('ramda');

function noop() {}

const isMDFile = R.compose(R.equals('.md'), path.extname);
exports.findMDFile = function findMDFile(fileName, shallow) {
const filePaths = Array.isArray(fileName) ? fileName : [fileName];
Expand All @@ -19,7 +19,7 @@ exports.findMDFile = function findMDFile(fileName, shallow) {
let hasIndexFile = false;
try {
hasIndexFile = fs.statSync(indexFile).isFile();
} catch (e) {}
} catch (e) { noop(); }

if (shallow && hasIndexFile) {
mds.push(indexFile);
Expand All @@ -34,6 +34,7 @@ exports.findMDFile = function findMDFile(fileName, shallow) {
return mds;
};

/* eslint prefer-template: 0 */
exports.stringify = function stringify(data, d) {
const depth = d || 1;
const indent = ' '.repeat(depth);
Expand Down
6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const webpack = require('atool-build/lib/webpack');

module.exports = function(webpackConfig) {
module.exports = function (webpackConfig) {
// remove common.js
webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => {
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
Expand Down Expand Up @@ -38,7 +38,7 @@ module.exports = function(webpackConfig) {
webpackConfig.module.loaders.push({
test: /\.md$/,
exclude: [/node_modules/, componentRegExp],
loader: `babel!antd-md`,
loader: 'babel!antd-md',
});
}
}
Expand All @@ -49,7 +49,7 @@ module.exports = function(webpackConfig) {
'antd.min': entry,
};
webpackConfig.externals = {
'react': {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
Expand Down

0 comments on commit 7a6485d

Please sign in to comment.