add build switch for test code
This commit is contained in:
parent
2a797eb953
commit
deedfba851
@ -12,6 +12,7 @@ module.exports = (grunt) ->
|
|||||||
get: ->
|
get: ->
|
||||||
pkg = grunt.config 'pkg'
|
pkg = grunt.config 'pkg'
|
||||||
pkg.importHTML = importHTML
|
pkg.importHTML = importHTML
|
||||||
|
pkg.tests_enabled or= false
|
||||||
pkg
|
pkg
|
||||||
enumerable: true
|
enumerable: true
|
||||||
)
|
)
|
||||||
@ -185,6 +186,11 @@ module.exports = (grunt) ->
|
|||||||
|
|
||||||
grunt.log.ok 'pkg.type = %s', type
|
grunt.log.ok 'pkg.type = %s', type
|
||||||
|
|
||||||
|
grunt.registerTask 'enable-tests', 'Include testing code', () ->
|
||||||
|
pkg = grunt.config 'pkg'
|
||||||
|
pkg.tests_enabled = true
|
||||||
|
grunt.config 'pkg', pkg
|
||||||
|
|
||||||
grunt.registerTask 'build', [
|
grunt.registerTask 'build', [
|
||||||
'concurrent:build'
|
'concurrent:build'
|
||||||
]
|
]
|
||||||
@ -207,6 +213,12 @@ module.exports = (grunt) ->
|
|||||||
'clean:tmpuserscript'
|
'clean:tmpuserscript'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
grunt.registerTask 'build-tests', [
|
||||||
|
'enable-tests'
|
||||||
|
'build-userscript'
|
||||||
|
'build-crx'
|
||||||
|
]
|
||||||
|
|
||||||
grunt.registerTask 'testing', [
|
grunt.registerTask 'testing', [
|
||||||
'build'
|
'build'
|
||||||
'shell:pack'
|
'shell:pack'
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
<% if (tests_enabled) { %>
|
||||||
BuildTest =
|
BuildTest =
|
||||||
init: ->
|
init: ->
|
||||||
return if !Conf['Menu']
|
return if !Conf['Menu']
|
||||||
@ -51,3 +52,4 @@ BuildTest =
|
|||||||
g.posts.forEach (post) ->
|
g.posts.forEach (post) ->
|
||||||
unless post.isClone or post.isFetchedQuote or $ '.abbr', post.nodes.comment
|
unless post.isClone or post.isFetchedQuote or $ '.abbr', post.nodes.comment
|
||||||
BuildTest.runTest post
|
BuildTest.runTest post
|
||||||
|
<% } %>
|
||||||
|
|||||||
@ -330,7 +330,9 @@ Main =
|
|||||||
['Keybinds', Keybinds]
|
['Keybinds', Keybinds]
|
||||||
['Show Dice Roll', Dice]
|
['Show Dice Roll', Dice]
|
||||||
['Banner', Banner]
|
['Banner', Banner]
|
||||||
|
<% if (tests_enabled) { %>
|
||||||
['Build Test', BuildTest]
|
['Build Test', BuildTest]
|
||||||
|
<% } %>
|
||||||
]
|
]
|
||||||
|
|
||||||
Main.init()
|
Main.init()
|
||||||
|
|||||||
@ -3,6 +3,7 @@ class Post
|
|||||||
toString: -> @ID
|
toString: -> @ID
|
||||||
|
|
||||||
constructor: (root, @thread, @board, that={}) ->
|
constructor: (root, @thread, @board, that={}) ->
|
||||||
|
<% if (tests_enabled) { %>
|
||||||
root2 = root.cloneNode true
|
root2 = root.cloneNode true
|
||||||
for el in $$ '.mobile', root2
|
for el in $$ '.mobile', root2
|
||||||
$.rm el
|
$.rm el
|
||||||
@ -15,6 +16,7 @@ class Post
|
|||||||
for el in $$ 'img[src]', root2
|
for el in $$ 'img[src]', root2
|
||||||
el.src = el.src.replace /^(\w+:\/\/)[0-2](\.t\.4cdn\.org\/)/, '$10$2'
|
el.src = el.src.replace /^(\w+:\/\/)[0-2](\.t\.4cdn\.org\/)/, '$10$2'
|
||||||
@normalizedOriginal = root2
|
@normalizedOriginal = root2
|
||||||
|
<% } %>
|
||||||
|
|
||||||
@ID = +root.id[2..]
|
@ID = +root.id[2..]
|
||||||
@fullID = "#{@board}.#{@ID}"
|
@fullID = "#{@board}.#{@ID}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user