Full Code of fmal/gulp-inline-source for AI

master 213d9346bec9 cached
24 files
9.9 KB
3.5k tokens
8 symbols
1 requests
Download .txt
Repository: fmal/gulp-inline-source
Branch: master
Commit: 213d9346bec9
Files: 24
Total size: 9.9 KB

Directory structure:
gitextract_unj3s5mj/

├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── index.js
├── package.json
└── test/
    ├── expected/
    │   ├── inlined-image-png.html
    │   ├── inlined-image-svg.html
    │   ├── inlined-link.html
    │   ├── inlined-nominify.html
    │   ├── inlined-script.html
    │   └── inlined-with-attributes.html
    ├── fixtures/
    │   ├── image-png.html
    │   ├── image-svg.html
    │   ├── link.html
    │   ├── nominify.html
    │   ├── script-es6.html
    │   ├── script-es6.js
    │   ├── script-relative.html
    │   ├── script.html
    │   ├── script.js
    │   ├── style.css
    │   └── with-attributes.html
    └── main.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
node_modules/
npm-debug.log
*.sublime-*


================================================
FILE: .travis.yml
================================================
language: node_js
cache:
  directories:
    - node_modules
    - ~/.npm
node_js:
  - "9"
  - "7.6"
after_success:
  - npm run travis-deploy-once "npm run semantic-release"
branches:
  except:
    - /^v\d+\.\d+\.\d+$/


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2014 Filip Malinowski

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


================================================
FILE: README.md
================================================
# gulp-inline-source

[![NPM Version](https://img.shields.io/npm/v/gulp-inline-source.svg?style=flat-square)](https://www.npmjs.com/package/gulp-inline-source)
[![Build Status](https://img.shields.io/travis/fmal/gulp-inline-source/master.svg?style=flat-square)](http://travis-ci.org/fmal/gulp-inline-source) 
[![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)

> Inline all `<script>`, `<link>` and `<img>` tags that contain the `inline` attribute with [inline-source](https://github.com/popeindustries/inline-source).

## How it works

```html
<!-- located at src/html/index.html -->
<html>
  <head>
    <!-- inline src/js/inlineScript.js -->
    <script src="../js/inlineScript.js" inline></script>
  </head>
  <body>
  </body>
</html>
```

```js
// located at src/js/inlineScript.js

function test() {
  var foo = 'lorem ipsum';
  return foo;
}
```

Output:
```html
<html>
  <head>
    <script>function test(){var a="lorem ipsum";return a}</script>
  </head>
  <body>
  </body>
</html>
```

## Install

```bash
$ npm install gulp-inline-source --save-dev
```

## Usage

```javascript
var gulp = require('gulp');
var inlinesource = require('gulp-inline-source');

gulp.task('inlinesource', function () {
    return gulp.src('./src/*.html')
        .pipe(inlinesource())
        .pipe(gulp.dest('./out'));
});
```

Optionally, you can provide [some options](https://github.com/popeindustries/inline-source#usage) through an options object:

```javascript
var gulp = require('gulp');
var inlinesource = require('gulp-inline-source');

gulp.task('inlinesource', function () {
    var options = {
        compress: false
    };

    return gulp.src('./src/*.html')
        .pipe(inlinesource(options))
        .pipe(gulp.dest('./out'));
});
```


================================================
FILE: index.js
================================================
'use strict';

const { inlineSource } = require('inline-source');
const PluginError = require('plugin-error');
const path = require('path');
const through = require('through2');

const PLUGIN_NAME = 'gulp-inline-source';

function gulpInlineSource (options) {
    return through.obj(function (file, enc, cb) {
        var self = this;

        if (file.isNull() || file.isDirectory()) {
            this.push(file);
            return cb();
        }

        if (file.isStream()) {
            this.emit('error', new PluginError(PLUGIN_NAME, 'Streaming not supported'));
            return cb();
        }

        var fileOptions = {
            rootpath: path.dirname(file.path),
            htmlpath: file.path
        };

        if (options) {
            for (var i in options) {
                fileOptions[i] = options[i];
            }
        }

        inlineSource(file.contents.toString(), fileOptions)
            .then(html => {
                file.contents = Buffer.from(html || '');
                self.push(file);
                cb();
            })
            .catch(err => {
                self.emit('error', new PluginError(PLUGIN_NAME, err));
            });
    });
}

module.exports = gulpInlineSource;


================================================
FILE: package.json
================================================
{
  "name": "gulp-inline-source",
  "version": "0.0.0-development",
  "description": "Inline flagged js & css sources.",
  "license": "MIT",
  "author": "Filip Malinowski <filip@fmal.me>",
  "repository": "git://github.com/fmal/gulp-inline-source.git",
  "keywords": [
    "gulpplugin",
    "inline",
    "css",
    "javascript"
  ],
  "engines": {
    "node": ">=7.6"
  },
  "scripts": {
    "test": "tape test/*.js | faucet",
    "commit": "git-cz",
    "commitmsg": "validate-commit-msg",
    "prepush": "npm test",
    "semantic-release": "semantic-release",
    "travis-deploy-once": "travis-deploy-once"
  },
  "dependencies": {
    "plugin-error": "~1.0.1",
    "inline-source": "~6.1.8",
    "through2": "~2.0.0"
  },
  "main": "index.js",
  "devDependencies": {
    "commitizen": "^2.9.6",
    "cz-conventional-changelog": "^2.0.0",
    "faucet": "0.0.1",
    "husky": "^0.13.3",
    "semantic-release": "^15.6.0",
    "tape": "^4.0.1",
    "travis-deploy-once": "^5.0.0",
    "validate-commit-msg": "^2.14.0",
    "vinyl": "^2.1.0"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
}


================================================
FILE: test/expected/inlined-image-png.html
================================================
<html>
  <head>
  </head>
  <body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAKtJREFUaAXt0rERwDAMw0A5+++cuEiHDSD4Tg078n1m5r235j1rmv5FK2wXTzhh2QJ9aRko6iSMSWRBwjJQ1EkYk8iChGWgqJMwJpEFCctAUSdhTCILEpaBok7CmEQWJCwDRZ2EMYksSFgGijoJYxJZkLAMFHUSxiSyIGEZKOokjElkQcIyUNRJGJPIgoRloKiTMCaRBQnLQFEnYUwiCxKWgaJOwphEFqwT/gC5HwF3y7W1swAAAABJRU5ErkJggg=="/>
  </body>
</html>

================================================
FILE: test/expected/inlined-image-svg.html
================================================
<html>
  <head>
  </head>
  <body>
    <svg width="60" height="60" viewBox="0 0 60 60"><path fill="#000" d="M0 0h60v60H0z" fill-rule="evenodd"/></svg>
  </body>
</html>


================================================
FILE: test/expected/inlined-link.html
================================================
<html>
  <head>
	<style>.classname{color:red}</style>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/expected/inlined-nominify.html
================================================
<html>
  <head>
	<script>function test() {
  var foo = 'lorem ipsum';
  return foo;
}</script>
	<style>.classname {
	color: red;
}</style>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/expected/inlined-script.html
================================================
<html>
  <head>
	<script>function test(){return"lorem ipsum"}</script>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/expected/inlined-with-attributes.html
================================================
<html>
  <head>
	<script>function test(){return"lorem ipsum"}</script>
	<style type="text/css" media="screen">.classname{color:red}</style>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/fixtures/image-png.html
================================================
<html>
  <head>
  </head>
  <body>
    <img src="image.png" inline>
  </body>
</html>

================================================
FILE: test/fixtures/image-svg.html
================================================
<html>
  <head>
  </head>
  <body>
    <img src="image.svg" inline>
  </body>
</html>


================================================
FILE: test/fixtures/link.html
================================================
<html>
  <head>
	<link rel="stylesheet" href="style.css" inline>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/fixtures/nominify.html
================================================
<html>
  <head>
	<script src="script.js" inline></script>
	<link rel="stylesheet" href="style.css" inline>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/fixtures/script-es6.html
================================================
<html>
  <head>
	<script src="script-es6.js" inline></script>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/fixtures/script-es6.js
================================================
function test() {
  const foo = `lorem ipsum`;
  return foo;
}

================================================
FILE: test/fixtures/script-relative.html
================================================
<html>
  <head>
	<script src="../fixtures/script.js" inline></script>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/fixtures/script.html
================================================
<html>
  <head>
	<script src="script.js" inline></script>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/fixtures/script.js
================================================
function test() {
  var foo = 'lorem ipsum';
  return foo;
}

================================================
FILE: test/fixtures/style.css
================================================
.classname {
	color: red;
}

================================================
FILE: test/fixtures/with-attributes.html
================================================
<html>
  <head>
	<script src="script.js" inline></script>
	<link rel="stylesheet" href="style.css" type="text/css" media="screen" inline>
  </head>
  <body>
  </body>
</html>

================================================
FILE: test/main.js
================================================
'use strict';

const path = require('path');
const Vinyl = require('vinyl');
const fs = require('fs');
const test = require('tape');
const inlinesource = require('../');

function getFile (filePath, contents) {
    return new Vinyl({
        path: filePath,
        base: path.dirname(filePath),
        contents: contents || fs.readFileSync(filePath)
    });
}

function getFixture (filePath) {
    return getFile(path.join(__dirname, 'fixtures', filePath));
}

function getExpected (filePath) {
    return getFile(path.join(__dirname, 'expected', filePath));
}

function compare (stream, fixtureName, expectedName, t) {
    stream.on('data', function (newFile) {
        t.equal(String(newFile.contents), String(getExpected(expectedName).contents));
    });

    stream.on('end', function () {
        t.end();
    });

    stream.write(getFixture(fixtureName));
    stream.end();
}

test('inlines <script> tag', function (t) {
    compare(inlinesource(), 'script.html', 'inlined-script.html', t);
});

test('inlines <link> tag', function (t) {
    compare(inlinesource(), 'link.html', 'inlined-link.html', t);
});

test('inlines <img> tag with SVG source', function (t) {
    compare(inlinesource(), 'image-svg.html', 'inlined-image-svg.html', t);
});

test('inlines <img> tag with PNG source', function (t) {
    compare(inlinesource(), 'image-png.html', 'inlined-image-png.html', t);
});

test('works with type and media attributes', function (t) {
    compare(inlinesource(), 'with-attributes.html', 'inlined-with-attributes.html', t);
});

test('works with relative paths', function (t) {
    compare(inlinesource(), 'script-relative.html', 'inlined-script.html', t);
});

test('inlines assets without minification', function (t) {
    const stream = inlinesource({
        compress: false
    });

    compare(stream, 'nominify.html', 'inlined-nominify.html', t);
});

test('throws when trying to compress non-ES5 syntax', function (t) {
    t.plan(1);

    const stream = inlinesource({ compress: true });

    stream.on('error', function (err) {
        t.pass();
    });

    stream.on('finish', function () {
        t.end();
    });

    stream.write(getFixture('script-es6.html'));
    stream.end();
});
Download .txt
gitextract_unj3s5mj/

├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── index.js
├── package.json
└── test/
    ├── expected/
    │   ├── inlined-image-png.html
    │   ├── inlined-image-svg.html
    │   ├── inlined-link.html
    │   ├── inlined-nominify.html
    │   ├── inlined-script.html
    │   └── inlined-with-attributes.html
    ├── fixtures/
    │   ├── image-png.html
    │   ├── image-svg.html
    │   ├── link.html
    │   ├── nominify.html
    │   ├── script-es6.html
    │   ├── script-es6.js
    │   ├── script-relative.html
    │   ├── script.html
    │   ├── script.js
    │   ├── style.css
    │   └── with-attributes.html
    └── main.js
Download .txt
SYMBOL INDEX (8 symbols across 4 files)

FILE: index.js
  constant PLUGIN_NAME (line 8) | const PLUGIN_NAME = 'gulp-inline-source';
  function gulpInlineSource (line 10) | function gulpInlineSource (options) {

FILE: test/fixtures/script-es6.js
  function test (line 1) | function test() {

FILE: test/fixtures/script.js
  function test (line 1) | function test() {

FILE: test/main.js
  function getFile (line 9) | function getFile (filePath, contents) {
  function getFixture (line 17) | function getFixture (filePath) {
  function getExpected (line 21) | function getExpected (filePath) {
  function compare (line 25) | function compare (stream, fixtureName, expectedName, t) {
Condensed preview — 24 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (12K chars).
[
  {
    "path": ".gitignore",
    "chars": 40,
    "preview": "node_modules/\nnpm-debug.log\n*.sublime-*\n"
  },
  {
    "path": ".travis.yml",
    "chars": 217,
    "preview": "language: node_js\ncache:\n  directories:\n    - node_modules\n    - ~/.npm\nnode_js:\n  - \"9\"\n  - \"7.6\"\nafter_success:\n  - np"
  },
  {
    "path": "LICENSE",
    "chars": 1083,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2014 Filip Malinowski\n\nPermission is hereby granted, free of charge, to any person "
  },
  {
    "path": "README.md",
    "chars": 2022,
    "preview": "# gulp-inline-source\n\n[![NPM Version](https://img.shields.io/npm/v/gulp-inline-source.svg?style=flat-square)](https://ww"
  },
  {
    "path": "index.js",
    "chars": 1233,
    "preview": "'use strict';\n\nconst { inlineSource } = require('inline-source');\nconst PluginError = require('plugin-error');\nconst pat"
  },
  {
    "path": "package.json",
    "chars": 1150,
    "preview": "{\n  \"name\": \"gulp-inline-source\",\n  \"version\": \"0.0.0-development\",\n  \"description\": \"Inline flagged js & css sources.\","
  },
  {
    "path": "test/expected/inlined-image-png.html",
    "chars": 416,
    "preview": "<html>\n  <head>\n  </head>\n  <body>\n    <img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAA"
  },
  {
    "path": "test/expected/inlined-image-svg.html",
    "chars": 169,
    "preview": "<html>\n  <head>\n  </head>\n  <body>\n    <svg width=\"60\" height=\"60\" viewBox=\"0 0 60 60\"><path fill=\"#000\" d=\"M0 0h60v60H0"
  },
  {
    "path": "test/expected/inlined-link.html",
    "chars": 90,
    "preview": "<html>\n  <head>\n\t<style>.classname{color:red}</style>\n  </head>\n  <body>\n  </body>\n</html>"
  },
  {
    "path": "test/expected/inlined-nominify.html",
    "chars": 175,
    "preview": "<html>\n  <head>\n\t<script>function test() {\n  var foo = 'lorem ipsum';\n  return foo;\n}</script>\n\t<style>.classname {\n\tcol"
  },
  {
    "path": "test/expected/inlined-script.html",
    "chars": 107,
    "preview": "<html>\n  <head>\n\t<script>function test(){return\"lorem ipsum\"}</script>\n  </head>\n  <body>\n  </body>\n</html>"
  },
  {
    "path": "test/expected/inlined-with-attributes.html",
    "chars": 176,
    "preview": "<html>\n  <head>\n\t<script>function test(){return\"lorem ipsum\"}</script>\n\t<style type=\"text/css\" media=\"screen\">.classname"
  },
  {
    "path": "test/fixtures/image-png.html",
    "chars": 85,
    "preview": "<html>\n  <head>\n  </head>\n  <body>\n    <img src=\"image.png\" inline>\n  </body>\n</html>"
  },
  {
    "path": "test/fixtures/image-svg.html",
    "chars": 86,
    "preview": "<html>\n  <head>\n  </head>\n  <body>\n    <img src=\"image.svg\" inline>\n  </body>\n</html>\n"
  },
  {
    "path": "test/fixtures/link.html",
    "chars": 101,
    "preview": "<html>\n  <head>\n\t<link rel=\"stylesheet\" href=\"style.css\" inline>\n  </head>\n  <body>\n  </body>\n</html>"
  },
  {
    "path": "test/fixtures/nominify.html",
    "chars": 143,
    "preview": "<html>\n  <head>\n\t<script src=\"script.js\" inline></script>\n\t<link rel=\"stylesheet\" href=\"style.css\" inline>\n  </head>\n  <"
  },
  {
    "path": "test/fixtures/script-es6.html",
    "chars": 98,
    "preview": "<html>\n  <head>\n\t<script src=\"script-es6.js\" inline></script>\n  </head>\n  <body>\n  </body>\n</html>"
  },
  {
    "path": "test/fixtures/script-es6.js",
    "chars": 62,
    "preview": "function test() {\n  const foo = `lorem ipsum`;\n  return foo;\n}"
  },
  {
    "path": "test/fixtures/script-relative.html",
    "chars": 106,
    "preview": "<html>\n  <head>\n\t<script src=\"../fixtures/script.js\" inline></script>\n  </head>\n  <body>\n  </body>\n</html>"
  },
  {
    "path": "test/fixtures/script.html",
    "chars": 94,
    "preview": "<html>\n  <head>\n\t<script src=\"script.js\" inline></script>\n  </head>\n  <body>\n  </body>\n</html>"
  },
  {
    "path": "test/fixtures/script.js",
    "chars": 60,
    "preview": "function test() {\n  var foo = 'lorem ipsum';\n  return foo;\n}"
  },
  {
    "path": "test/fixtures/style.css",
    "chars": 27,
    "preview": ".classname {\n\tcolor: red;\n}"
  },
  {
    "path": "test/fixtures/with-attributes.html",
    "chars": 174,
    "preview": "<html>\n  <head>\n\t<script src=\"script.js\" inline></script>\n\t<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" media"
  },
  {
    "path": "test/main.js",
    "chars": 2218,
    "preview": "'use strict';\n\nconst path = require('path');\nconst Vinyl = require('vinyl');\nconst fs = require('fs');\nconst test = requ"
  }
]

About this extraction

This page contains the full source code of the fmal/gulp-inline-source GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 24 files (9.9 KB), approximately 3.5k tokens, and a symbol index with 8 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!