Ind.ie is now
Small Technology Foundation
.
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Site
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
31
Issues
31
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Better
Site
Commits
91c77811
Unverified
Commit
91c77811
authored
Dec 06, 2016
by
Aral Balkan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incomplete: integrate cache into builder attempt.
parent
52cfa2ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
6 deletions
+32
-6
Blockdown.coffee
Blockdown.coffee
+11
-0
Builder.coffee
Builder.coffee
+2
-0
Cache2.coffee
Cache2.coffee
+19
-6
No files found.
Blockdown.coffee
View file @
91c77811
...
...
@@ -43,6 +43,8 @@ GlobalStatistics = require './GlobalStatistics'
require
'./StringExtensions'
# for String::trim()
crypto
=
require
'crypto'
class
Blockdown
...
...
@@ -1173,4 +1175,13 @@ Better is a Safari content blocker for <a href='https://itunes.apple.com/us/app/
expect
(
validValues
.
size
,
"All
#{
parentObjectsHumanName
}
#{
propertysHumanName
}
values should be valid."
).
to
.
equal
actualValues
.
size
#
# Calculate checksum
#
checksum
=
(
str
)
->
return
crypto
.
createHash
(
'md5'
)
.
update
(
str
,
'utf8'
)
.
digest
(
'hex'
)
module
.
exports
=
Blockdown
Builder.coffee
View file @
91c77811
...
...
@@ -30,6 +30,8 @@ exec = (require 'child_process').exec
touch
=
require
'touch'
cache
=
require
'./Cache2'
class
Builder
instance
=
null
...
...
Cache2.coffee
View file @
91c77811
...
...
@@ -20,18 +20,30 @@ class Cache
cacheCurrentChecksumsDirectory
:
null
lastModifiedTimes
:
null
constructor
:
->
@
homeDirectory
=
path
.
join
path
.
homedir
(),
'better.fyi'
@
contentDirectory
=
path
.
join
@
homeDirectory
,
'content'
@
themesDirectory
=
path
.
join
@
homeDirectory
,
'themes'
@
cacheCurrentModifiedTimesFile
=
path
.
join
@
homeDirectory
,
'.private'
,
'cache'
,
'current-modified-times.json'
@
cachePreviousModifiedTimesFile
=
path
.
join
@
homeDirectory
,
'.private'
,
'cache'
,
'previous-modified-times.json'
@
lastModifiedTimes
=
{}
build
:
=>
startTime
=
new
Date
# Back up the current modified times file
if
fs
.
existsSync
@
cacheCurrentModifiedTimesFile
fs
.
copySync
@
cacheCurrentModifiedTimesFile
,
@
cachePreviousModifiedTimesFile
@
cacheContent
@
contentDirectory
.
then
=>
@
cacheContent
@
themesDirectory
.
then
=>
fs
.
outputFileAsync
@
cacheCurrentModifiedTimesFile
,
JSON
.
stringify
@
lastModifiedTimes
,
null
,
" "
.
then
=>
duration
=
(
new
Date
)
-
startTime
console
.
log
"Took:
#{
duration
}
ms"
...
...
@@ -39,8 +51,6 @@ class Cache
cacheContent
:
(
directory
)
=>
lastModifiedTimes
=
{}
(
globAsync
"
#{
directory
}
/**/*"
,
{
nodir
:
true
})
.
series
(
file
)
=>
...
...
@@ -49,8 +59,11 @@ class Cache
# Using the sync version of stat is a little faster here
stats
=
fs
.
statSync
file
lastModifiedTimes
[
filePathFragment
]
=
stats
.
mtime
.
then
=>
fs
.
outputFileAsync
@
cacheCurrentModifiedTimesFile
,
JSON
.
stringify
lastModifiedTimes
@
lastModifiedTimes
[
filePathFragment
]
=
stats
.
mtime
module
.
exports
=
Cache
# Test
cache
=
new
Cache
cache
.
build
()
new
Cache
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment