[Pkg-javascript-commits] [node-string-decoder] 02/27: added and adapted scraper from readable-stream

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 11 15:12:30 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-string-decoder.

commit f26b3346d7c3c9d49bf7977af21867bf87d63e56
Author: Rod Vagg <rod at vagg.org>
Date:   Fri Jan 17 21:27:37 2014 +1100

    added and adapted scraper from readable-stream
---
 .gitignore                 |  1 +
 build/.gitignore           |  1 +
 build/build.js             | 94 ++++++++++++++++++++++++++++++++++++++++++++++
 build/files.js             | 12 ++++++
 build/package.json         | 12 ++++++
 build/test-replacements.js | 24 ++++++++++++
 6 files changed, 144 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b512c09
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
\ No newline at end of file
diff --git a/build/.gitignore b/build/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/build/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/build/build.js b/build/build.js
new file mode 100755
index 0000000..46470cf
--- /dev/null
+++ b/build/build.js
@@ -0,0 +1,94 @@
+#!/usr/bin/env node
+
+const hyperquest  = require('hyperzip')(require('hyperdirect'))
+    , bl          = require('bl')
+    , fs          = require('fs')
+    , path        = require('path')
+    , cheerio     = require('cheerio')
+
+    , files       = require('./files')
+    , testReplace = require('./test-replacements')
+
+    , srcurlpfx   = 'https://raw.github.com/joyent/node/v' + process.argv[2] + '-release/'
+    , libsrcurl   = srcurlpfx + 'lib/'
+    , testsrcurl  = srcurlpfx + 'test/simple/'
+    , testlisturl = 'https://github.com/joyent/node/tree/v' + process.argv[2] + '-release/test/simple'
+    , libourroot  = path.join(__dirname, '../')
+    , testourroot = path.join(__dirname, '../test/simple/')
+
+
+function processFile (url, out, replacements) {
+  hyperquest(url).pipe(bl(function (err, data) {
+    if (err)
+      throw err
+
+    data = data.toString()
+    replacements.forEach(function (replacement) {
+      data = data.replace.apply(data, replacement)
+    })
+
+    fs.writeFile(out, data, 'utf8', function (err) {
+      if (err)
+        throw err
+
+      console.log('Wrote', out)
+    })
+  }))
+}
+
+function processLibFile (file) {
+  var replacements = files[file]
+    , url          = libsrcurl + file
+    , out          = path.join(libourroot, replacements.out || file)
+
+  processFile(url, out, replacements)
+}
+
+
+function processTestFile (file) {
+  var replacements = testReplace.all
+    , url          = testsrcurl + file
+    , out          = path.join(testourroot, file)
+
+  if (testReplace[file])
+    replacements = replacements.concat(testReplace[file])
+
+  processFile(url, out, replacements)
+}
+
+
+if (!/0\.1\d\.\d+/.test(process.argv[2])) {
+  console.log('Usage: build.js <node version>')
+  return process.exit(-1)
+}
+
+
+//--------------------------------------------------------------------
+// Grab & process files in ../lib/
+
+Object.keys(files).forEach(processLibFile)
+
+//--------------------------------------------------------------------
+// Discover, grab and process all test-string-decoder* files on joyent/node
+
+hyperquest(testlisturl).pipe(bl(function (err, data) {
+  if (err)
+    throw err
+
+  var $ = cheerio.load(data.toString())
+
+  $('table.files .js-directory-link').each(function () {
+    var file = $(this).text()
+    if (/^test-string-decoder/.test(file) || file == 'common.js')
+      processTestFile(file)
+  })
+}))
+
+//--------------------------------------------------------------------
+// Grab the joyent/node test/common.js
+
+processFile(
+    testsrcurl + '../common.js'
+  , path.join(testourroot, '../common.js')
+  , testReplace['common.js']
+)
\ No newline at end of file
diff --git a/build/files.js b/build/files.js
new file mode 100644
index 0000000..9ef7564
--- /dev/null
+++ b/build/files.js
@@ -0,0 +1,12 @@
+/* This file lists the files to be fetched from the node repo
+ * in the /lib/ directory which will be placed in the ../lib/
+ * directory after having each of the "replacements" in the
+ * array for that file applied to it. The replacements are
+ * simply the arguments to String#replace, so they can be
+ * strings, regexes, functions.
+ */
+
+module.exports['string_decoder.js'] = [
+]
+
+module.exports['string_decoder.js'].out = 'index.js'
\ No newline at end of file
diff --git a/build/package.json b/build/package.json
new file mode 100644
index 0000000..f7ee6a4
--- /dev/null
+++ b/build/package.json
@@ -0,0 +1,12 @@
+{
+  "name": "string_decoder-build",
+  "version": "0.0.0",
+  "description": "",
+  "main": "build.js",
+  "dependencies": {
+    "bl": "~0.6.0",
+    "hyperzip": "0.0.0",
+    "hyperdirect": "0.0.0",
+    "cheerio": "~0.13.1"
+  }
+}
diff --git a/build/test-replacements.js b/build/test-replacements.js
new file mode 100644
index 0000000..5bbf602
--- /dev/null
+++ b/build/test-replacements.js
@@ -0,0 +1,24 @@
+module.exports.all = [
+    [
+        /require\(['"]string_decoder['"]\)/g
+      , 'require(\'../../\')'
+    ]
+
+]
+
+module.exports['common.js'] = [
+    [
+        /^                      setImmediate,$/m
+      , '                      typeof setImmediate == \'undefined\' ? null : setImmediate,'
+    ]
+
+  , [
+        /^                      clearImmediate,$/m
+      , '                      typeof clearImmediate == \'undefined\' ? null : clearImmediate,'
+    ]
+
+  , [
+        /^                      global];$/m
+      , '                      global].filter(Boolean);'
+    ]
+]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-string-decoder.git



More information about the Pkg-javascript-commits mailing list