Skip to content

Commit

Permalink
feat: support nodejs@0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed May 22, 2016
1 parent 1f4c3c3 commit 0bd7bf2
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 30 deletions.
7 changes: 7 additions & 0 deletions .babelrc
@@ -0,0 +1,7 @@
{
"presets": ["es2015"],
"plugins": [
"transform-runtime",
"add-module-exports"
]
}
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -31,3 +31,5 @@ node_modules

# Optional REPL history
.node_repl_history

dist
4 changes: 4 additions & 0 deletions .travis.yml
@@ -1,6 +1,7 @@
language: node_js
sudo: false
node_js:
- v0.10
- v4

cache:
Expand All @@ -12,6 +13,9 @@ before_install:
install:
- npm install

script:
- if [[ $TRAVIS_NODE_VERSION == "v0.10" ]]; then npm run test-es5; fi;
- if [[ $TRAVIS_NODE_VERSION != "v0.10" ]]; then npm run test; fi;
after_success:
- npm run coveralls
- npm run semantic-release
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -46,7 +46,8 @@ independent({
<!--@dependencies({ shield: 'flat-square' })-->
## <a name="dependencies">Dependencies</a> [![dependency status](https://img.shields.io/david/zkochan/independent/master.svg?style=flat-square)](https://david-dm.org/zkochan/independent/master)

- [@zkochan/async-replace](https://github.com/zkochan/async-replace): Regex replacements using asynchronous callback functions
- [babel-runtime](https://github.com/babel/babel/blob/master/packages): babel selfContained runtime
- [@zkochan/async-replace](https://github.com/zkochan/async-replace): String replace using asynchronous replacement functions
- [read-pkg-up](https://github.com/sindresorhus/read-pkg-up): Read the closest package.json file
- [relative](https://github.com/jonschlinkert/relative): Get the relative filepath from path A to path B. Calculates from file-to-directory, file-to-file, directory-to-file, and directory-to-directory.
- [resolve](https://github.com/substack/node-resolve): resolve like require.resolve() on behalf of files asynchronously and synchronously
Expand All @@ -56,6 +57,11 @@ independent({
<!--@devDependencies({ shield: 'flat-square' })-->
## <a name="dev-dependencies">Dev Dependencies</a> [![devDependency status](https://img.shields.io/david/dev/zkochan/independent/master.svg?style=flat-square)](https://david-dm.org/zkochan/independent/master#info=devDependencies)

- [babel-cli](https://github.com/babel/babel/blob/master/packages): Babel command line.
- [babel-plugin-add-module-exports](https://github.com/59naga/babel-plugin-add-module-exports): Fix babel/babel#2212
- [babel-plugin-transform-runtime](https://github.com/babel/babel/blob/master/packages): Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals
- [babel-preset-es2015](https://github.com/babel/babel/blob/master/packages): Babel preset for all es2015 plugins.
- [babel-register](https://github.com/babel/babel/blob/master/packages): babel require hook
- [chai](https://github.com/chaijs/chai): BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
- [cz-conventional-changelog](https://github.com/commitizen/cz-conventional-changelog): Commitizen adapter following the conventional-changelog format.
- [eslint](https://github.com/eslint/eslint): An AST-based pattern checker for JavaScript.
Expand Down
2 changes: 1 addition & 1 deletion example/index.js
@@ -1,5 +1,5 @@
'use strict'
const independent = require('..')
const independent = require('../dist/index')

independent({
code: "require('./bar')",
Expand Down
2 changes: 0 additions & 2 deletions index.js

This file was deleted.

29 changes: 20 additions & 9 deletions package.json
Expand Up @@ -3,20 +3,25 @@
"version": "0.0.0-placeholder",
"description": "Change relative requires to import actual modules",
"files": [
"index.js",
"lib"
"src/",
"dist/"
],
"main": "index.js",
"main": "dist/index.js",
"jsnext:main": "src/index.js",
"scripts": {
"test": "mocha && npm run lint && mos test",
"lint": "eslint lib/**/*.js index.js",
"test-es5": "mocha --compilers js:babel-register && npm run lint",
"test:md": "npm run transpile && mos test",
"test": "npm run test-es5 && npm run test:md",
"lint": "eslint src/ example/",
"commit": "git-cz",
"coverage": "istanbul cover -x \"**/*.spec.js\" node_modules/mocha/bin/_mocha -- -R spec",
"precoveralls": "istanbul cover -x \"**/*.spec.js\" node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && npm i coveralls@2",
"coverage": "istanbul cover -x \"**/*.spec.js\" node_modules/mocha/bin/_mocha -- --compilers js:babel-register -R spec",
"precoveralls": "istanbul cover -x \"**/*.spec.js\" node_modules/mocha/bin/_mocha --report lcovonly -- --compilers js:babel-register -R spec && npm i coveralls@2",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"postcoveralls": "rm -rf ./coverage",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"md": "mos"
"md": "npm run transpile && mos",
"transpile": "babel src --out-dir dist",
"prepublish": "npm run transpile"
},
"repository": {
"type": "git",
Expand All @@ -43,12 +48,18 @@
}
},
"dependencies": {
"@zkochan/async-replace": "0.3.0",
"babel-runtime": "^6.9.0",
"@zkochan/async-replace": "^0.4.1",
"read-pkg-up": "1.0.1",
"relative": "3.0.2",
"resolve": "1.1.7"
},
"devDependencies": {
"babel-cli": "^6.9.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"chai": "^3.4.1",
"cz-conventional-changelog": "1.1.5",
"eslint": "2.8.0",
Expand Down
15 changes: 6 additions & 9 deletions lib/index.js → src/index.js
@@ -1,13 +1,10 @@
'use strict'
module.exports = independent
import path from 'path'
import resolve from 'resolve'
import relative from 'relative'
import readPkgUp from 'read-pkg-up'
import asyncReplace from '@zkochan/async-replace'

const path = require('path')
const resolve = require('resolve')
const relative = require('relative')
const readPkgUp = require('read-pkg-up')
const asyncReplace = require('@zkochan/async-replace')

function independent (opts) {
export default function independent (opts) {
opts = opts || {}

if (!opts.code) throw new Error('opts.code is required')
Expand Down
12 changes: 5 additions & 7 deletions lib/index.spec.js → src/index.spec.js
@@ -1,10 +1,8 @@
'use strict'
const describe = require('mocha').describe
const it = require('mocha').it
const expect = require('chai').expect
const fs = require('fs')
const path = require('path')
const independent = require('.')
import {describe, it} from 'mocha'
import {expect} from 'chai'
import fs from 'fs'
import path from 'path'
import independent from './index'

describe('independent', () => {
it('should replace relative require path with package name', () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/mocha.opts
@@ -1 +1 @@
lib/**/*.spec.js
src/**/*.spec.js

0 comments on commit 0bd7bf2

Please sign in to comment.