Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab1b83a

Browse files
committed
Remove generated files from repo, make tests independent from generated files
1 parent 72f5df4 commit ab1b83a

787 files changed

Lines changed: 474 additions & 10069 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ dist
1010
lib
1111
.nyc_output
1212
*.bak
13+
*.generated.js

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
- script: 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run test:browserstack; else true; fi'
1919
node_js: lts/*
2020
name: Browserstack Test
21-
- script: npm run build && npm run test:dist
21+
- script: npm run build-and-test
2222
node_js: lts/*
23-
name: Bundling Test
23+
name: Build Test
2424
- script: npm run coverage && npx codecov
2525
node_js: lts/*
2626
name: Coverage

bin/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const PRECISION = 14 // decimals
5858
* @return {*}
5959
*/
6060
function getMath () {
61-
return require('../lib/entry/bundleAny')
61+
return require('../lib/bundleAny')
6262
}
6363

6464
/**

bin/repl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This simply preloads mathjs and drops you into a REPL to
55
* help interactive debugging.
66
**/
7-
global.math = require('../lib/entry/bundleAny')
7+
global.math = require('../lib/bundleAny')
88
const repl = require('repl')
99

1010
repl.start({ useGlobal: true })

docs/reference/functions/typeof.md

Lines changed: 0 additions & 75 deletions
This file was deleted.

gulpfile.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22
const fs = require('fs')
33
const path = require('path')
44
const gulp = require('gulp')
5+
const del = require('del')
56
const log = require('fancy-log')
67
const webpack = require('webpack')
78
const babel = require('gulp-babel')
89
const uglify = require('uglify-js')
910
const docgenerator = require('./tools/docgenerator')
1011
const entryGenerator = require('./tools/entryGenerator')
1112
const validateAsciiChars = require('./tools/validateAsciiChars')
13+
const { validateEmbeddedDocs } = require('./tools/validateEmbeddedDocs')
1214

13-
const ENTRY = './src/entry/bundleAny.js'
15+
const ENTRY = './src/bundleAny.js'
1416
const HEADER = './src/header.js'
1517
const VERSION = './src/version.js'
1618
const COMPILE_SRC = './src/**/*.js'
19+
const COMPILE_ENTRY_SRC = './src/entry/**/*.js'
1720
const COMPILE_LIB = './lib'
21+
const COMPILE_ENTRY_LIB = './lib/entry'
1822
const COMPILED_MAIN_ANY = './lib/entry/mainAny.js'
1923
const FILE = 'math.js'
2024
const FILE_MIN = 'math.min.js'
@@ -136,7 +140,14 @@ function compile () {
136140
.pipe(babel())
137141
.pipe(gulp.dest(COMPILE_LIB))
138142
}
139-
function writeBanner (cb) {
143+
144+
function compileEntryFiles () {
145+
return gulp.src(COMPILE_ENTRY_SRC)
146+
.pipe(babel())
147+
.pipe(gulp.dest(COMPILE_ENTRY_LIB))
148+
}
149+
150+
function writeCompiledHeader (cb) {
140151
fs.writeFileSync(COMPILED_HEADER, createBanner())
141152
cb()
142153
}
@@ -168,22 +179,6 @@ function minify (done) {
168179
done()
169180
}
170181

171-
function validate (done) {
172-
const childProcess = require('child_process')
173-
174-
// this is run in a separate process as the modules need to be reloaded
175-
// with every validation (and required modules stay in cache).
176-
childProcess.execFile('node', ['./tools/validateEmbeddedDocs'], function (err, stdout, stderr) {
177-
if (err instanceof Error) {
178-
throw err
179-
}
180-
process.stdout.write(stdout)
181-
process.stderr.write(stderr)
182-
183-
done()
184-
})
185-
}
186-
187182
function validateAscii (done) {
188183
const Reset = '\x1b[0m'
189184
const BgRed = '\x1b[41m'
@@ -208,7 +203,7 @@ function validateAscii (done) {
208203
}
209204

210205
function generateDocs (done) {
211-
const all = require(REF_SRC + 'entry/bundleAny')
206+
const all = require(REF_SRC + 'bundleAny')
212207
const functionNames = Object.keys(all)
213208
.filter(key => typeof all[key] === 'function')
214209

@@ -260,14 +255,23 @@ gulp.task('watch', function watch () {
260255

261256
gulp.task('compile', compile)
262257

258+
function clean () {
259+
return del([
260+
'dist/**/*',
261+
'lib/**/*'
262+
])
263+
}
264+
263265
// The default task (called when you run `gulp`)
264266
gulp.task('default', gulp.series(
265-
bundle,
267+
clean,
266268
compile,
267-
writeBanner,
268269
generateEntryFiles,
270+
compileEntryFiles,
271+
writeCompiledHeader,
269272
addDeprecatedFunctions,
273+
bundle,
270274
minify,
271-
validate,
275+
validateEmbeddedDocs,
272276
generateDocs
273277
))

package-lock.json

Lines changed: 110 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"babel-loader": "8.0.5",
130130
"benchmark": "2.1.4",
131131
"codecov": "3.4.0",
132+
"del": "4.1.1",
132133
"expr-eval": "1.2.2",
133134
"fancy-log": "1.3.3",
134135
"glob": "7.1.4",
@@ -184,16 +185,17 @@
184185
],
185186
"scripts": {
186187
"build": "gulp",
187-
"build-and-test": "npm run build && npm run test:src && npm run test:dist && npm run lint",
188+
"build-and-test": "npm run build && npm run test:src && npm run test:generated && npm run test:node && npm run lint",
188189
"watch": "gulp watch",
189190
"lint": "standard --env=mocha --env=worker",
190191
"validate:ascii": "gulp validate:ascii",
191192
"test": "npm run test:src && npm run lint",
192-
"test:src": "mocha test test-node --recursive --require @babel/register",
193-
"test:dist": "mocha test-dist --recursive",
193+
"test:src": "mocha test --recursive --require @babel/register",
194+
"test:generated": "mocha test-generated --recursive --require @babel/register",
195+
"test:node": "mocha test-node --recursive",
194196
"test:browser": "karma start ./browser-test-config/local-karma.js",
195197
"test:browserstack": "karma start ./browser-test-config/browserstack-karma.js",
196-
"coverage": "nyc --reporter=lcov --reporter=text-summary mocha test test-node --recursive --require @babel/register && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
198+
"coverage": "nyc --reporter=lcov --reporter=text-summary mocha test --recursive --require @babel/register && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
197199
"prepublishOnly": "npm run build-and-test"
198200
},
199201
"bin": {

0 commit comments

Comments
 (0)