You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/12/18 17:59:02 UTC

[couchdb-escodegen] reference refs/pull/251/head created (now 4eac3d6)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to reference refs/pull/251/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git.


      at 4eac3d6  Fixed mistakes

This reference includes the following new commits:

     new 9c7f032  Converted escodegen.js to UMD format.
     new 4eac3d6  Fixed mistakes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb-escodegen] 02/02: Fixed mistakes

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to reference refs/pull/251/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git

commit 4eac3d64876bca632c982aded39c83ca28578ba3
Author: Oskar Segersvärd <vi...@gmail.com>
AuthorDate: Wed Aug 19 17:23:44 2015 +0200

    Fixed mistakes
    
    * Don't shadow variables
    * Don't try to access properties of possibly undefined sourceMap
    * Auto-update version
---
 escodegen.js            | 10 ++++++----
 package.json            |  1 +
 tools/update-version.js | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/escodegen.js b/escodegen.js
index 53c3467..b593c9f 100644
--- a/escodegen.js
+++ b/escodegen.js
@@ -71,7 +71,6 @@
         FORMAT_MINIFY,
         FORMAT_DEFAULTS;
 
-    SourceNode = sourceMap.SourceNode;
     Syntax = estraverse.Syntax;
 
     // Generation is done by generateExpression.
@@ -2499,14 +2498,17 @@
         safeConcatenation = options.format.safeConcatenation;
         directive = options.directive;
         parse = json ? null : options.parse;
-        sourceMap = options.sourceMap;
         sourceCode = options.sourceCode;
         preserveBlankLines = options.format.preserveBlankLines && sourceCode !== null;
         extra = options;
 
+        if (sourceMap) {
+          SourceNode = sourceMap.SourceNode;
+        }
+
         result = generateInternal(node);
 
-        if (!sourceMap) {
+        if (!options.sourceMap) {
             pair = {code: result.toString(), map: null};
             return options.sourceMapWithCode ? pair : pair.code;
         }
@@ -2545,7 +2547,7 @@
 
     FORMAT_DEFAULTS = getDefaultOptions().format;
 
-    exports.version = require('./package.json').version;
+    exports.version = '1.6.1';
     exports.generate = generate;
     exports.attachComments = estraverse.attachComments;
     exports.Precedence = updateDeeply({}, Precedence);
diff --git a/package.json b/package.json
index 4f21f69..94279b6 100644
--- a/package.json
+++ b/package.json
@@ -53,6 +53,7 @@
     },
     "license": "BSD-2-Clause",
     "scripts": {
+        "prepublish": "node tools/update-version.js",
         "test": "gulp travis",
         "unit-test": "gulp test",
         "lint": "gulp lint",
diff --git a/tools/update-version.js b/tools/update-version.js
new file mode 100644
index 0000000..351d5a8
--- /dev/null
+++ b/tools/update-version.js
@@ -0,0 +1,42 @@
+#!/usr/bin/env node
+/*
+  Copyright (C) 2012 Yusuke Suzuki <ut...@gmail.com>
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*jslint sloppy:true node:true */
+
+var fs = require('fs'),
+  path = require('path'),
+  version = require('../package.json').version;
+
+(function() {
+  var filename = path.resolve(__dirname, '../escodegen.js');
+
+  var source = fs.readFileSync(filename, { encoding: 'utf8' });
+
+  source = source.replace(
+    /exports\.version = '(\d+\.\d+\.\d+)';/,
+    'exports.version = \'' + version + '\';');
+
+  fs.writeFileSync(filename, source);
+}());


[couchdb-escodegen] 01/02: Converted escodegen.js to UMD format.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to reference refs/pull/251/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git

commit 9c7f03231385b95cf3bd5fb0a2b1d4a2ac51c376
Author: Oskar Segersvärd <vi...@gmail.com>
AuthorDate: Wed Aug 19 16:50:03 2015 +0200

    Converted escodegen.js to UMD format.
---
 escodegen.js | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/escodegen.js b/escodegen.js
index f706c05..53c3467 100644
--- a/escodegen.js
+++ b/escodegen.js
@@ -33,16 +33,23 @@
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-/*global exports:true, require:true, global:true*/
-(function () {
+/*global exports:true, require:true, define:true*/
+(function (global, factory) {
+  'use strict';
+  if (typeof exports === 'object' && typeof module !== 'undefined') {
+    factory(exports, require('estraverse'), require('esutils'), require('source-map'));
+  } else if (typeof define === 'function' && define.amd) {
+    define(['exports', 'estraverse', 'esutils', 'source-map'], factory);
+  } else {
+    factory(global.escodegen = {}, global.estraverse, global.esutils, global.sourceMap);
+  }
+})(this, function (exports, estraverse, esutils, sourceMap) {
     'use strict';
 
     var Syntax,
         Precedence,
         BinaryPrecedence,
         SourceNode,
-        estraverse,
-        esutils,
         isArray,
         base,
         indent,
@@ -59,15 +66,12 @@
         directive,
         extra,
         parse,
-        sourceMap,
         sourceCode,
         preserveBlankLines,
         FORMAT_MINIFY,
         FORMAT_DEFAULTS;
 
-    estraverse = require('estraverse');
-    esutils = require('esutils');
-
+    SourceNode = sourceMap.SourceNode;
     Syntax = estraverse.Syntax;
 
     // Generation is done by generateExpression.
@@ -2500,16 +2504,6 @@
         preserveBlankLines = options.format.preserveBlankLines && sourceCode !== null;
         extra = options;
 
-        if (sourceMap) {
-            if (!exports.browser) {
-                // We assume environment is node.js
-                // And prevent from including source-map by browserify
-                SourceNode = require('source-map').SourceNode;
-            } else {
-                SourceNode = global.sourceMap.SourceNode;
-            }
-        }
-
         result = generateInternal(node);
 
         if (!sourceMap) {
@@ -2558,5 +2552,5 @@
     exports.browser = false;
     exports.FORMAT_MINIFY = FORMAT_MINIFY;
     exports.FORMAT_DEFAULTS = FORMAT_DEFAULTS;
-}());
+});
 /* vim: set sw=4 ts=4 et tw=80 : */