Skip to content

Commit

Permalink
chore: update scirpts | npm
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed May 6, 2020
1 parent f91a14d commit 5d9699d
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 173 deletions.
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
**/npm-debug.log
**/node_modules
test
__tests__
src
build
gulpfile.js

.editorconfig
.prettierrc
Gemfile
jest.config.js
LICENSE.txt
Rakefile
express.js
.vscode
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"trailingComma": "none",
"arrowParens": "always",
"printWidth": 80,
"printWidth": 100,
"bracketSpacing": true,
"jsxBracketSameLine": true,
"tabWidth": 2,
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'fileutils'
gem 'sshkit'
gem 'semver'
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# next-is-promise
> Test whether an object looks like a promisesA+ promise
> Test whether an object looks like a promises-a+ promise.
## installation
```bash
npm install -S afeiship/next-is-promise --registry=https://registry.npm.taobao.org
npm install -S @feizheng/next-is-promise
```

## usage
```js
import '@feizheng/next-is-promise';

//DOCS here!
```

Expand Down
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Dir["./node_modules/@feizheng/rake-*/index.rake"].each do |task|
load task
end
12 changes: 12 additions & 0 deletions __tests__/api.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const nx = require('@feizheng/next-js-core2');
require('../src/next-is-promise');

describe('api.basic test', () => {
test('nx.isPromise', function() {
const obj1 = { name: 'fei' };
const obj2 = { email: '1290657123@qq.com' };
const result = {};
nx.isPromise(result, obj1, obj2);
expect(result.name, obj1.name).toBe(null);
});
});
4 changes: 2 additions & 2 deletions test/test.html → __tests__/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="../node_modules/next-js-core2/dist/next-js-core2.js"></script>
<script src="../src/next-is-promise.js"></script>
<script src="/node_modules/@feizheng/next-js-core2/dist/next-js-core2.js"></script>
<script src="/next-is-promise.js"></script>
</head>
<body>
<script>
Expand Down
28 changes: 0 additions & 28 deletions bower.json

This file was deleted.

10 changes: 3 additions & 7 deletions build/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
'use strict';

const gulp = require('gulp');
const config = require('./config');
const $ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'gulp.*', 'del']
});

//clean
gulp.task(
'clean',
gulp.parallel(function() {
return $.del('dist');
})
);
gulp.task('clean', function() {
return $.del('dist');
});
})();
29 changes: 0 additions & 29 deletions build/config.js

This file was deleted.

44 changes: 15 additions & 29 deletions build/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,23 @@
'use strict';

const gulp = require('gulp');
const config = require('./config');
const pkg = require('../package.json');
const saveLicense = require('uglify-save-license');
const $ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'gulp.*', 'del']
pattern: ['gulp-*', 'gulp.*', 'del', '@feizheng/gulp-*']
});

require('next-nice-comments');

const niceComments = nx.niceComments(
[
'name: <%= pkg.name %>',
'url: <%= pkg.homepage %>',
'version: <%= pkg.version %>',
'license: <%= pkg.license %>'
],
'js'
);

gulp.task(
'scripts',
gulp.parallel(function() {
return gulp
.src('src/*.js')
.pipe($.header(niceComments, { pkg: pkg }))
.pipe(gulp.dest('dist'))
.pipe($.size({ title: '[ default size ]:' }))
.pipe($.uglify(config.uglifyOptions))
.pipe($.rename({ extname: '.min.js' }))
.pipe(gulp.dest('dist'))
.pipe($.size({ title: '[ minimize size ]:' }));
})
);
gulp.task('scripts', function() {
return gulp
.src('src/*.js')
.pipe($.sourcemaps.init())
.pipe($.feizheng.pkgHeader())
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist'))
.pipe($.size({ title: '[ default size ]:' }))
.pipe($.ignore('*.js.map'))
.pipe($.uglify({ output: { comments: saveLicense } }))
.pipe($.rename({ extname: '.min.js' }))
.pipe(gulp.dest('dist'))
.pipe($.size({ title: '[ minimize size ]:' }));
});
})();
23 changes: 0 additions & 23 deletions build/version.js

This file was deleted.

20 changes: 10 additions & 10 deletions dist/next-is-promise.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/next-is-promise.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions dist/next-is-promise.min.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*!
* name: next-is-promise
* url: https://github.com/afeiship/next-is-promise
* name: @feizheng/next-is-promise
* description: Test whether an object looks like a promises-a+ promise.
* homepage: https://github.com/afeiship/next-is-promise
* version: 1.0.0
* date: 2020-05-06T00:25:49.825Z
* license: MIT
*/
!function(){var e=e||this||window||Function("return this")(),o=e.nx||require("next-js-core2");o.isPromise=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof obj.then},"undefined"!=typeof module&&module.exports&&(module.exports=o.isPromise)}();
!function(){var e=e||this||window||Function("return this")(),o=e.nx||require("@feizheng/next-js-core2"),n="function";o.isPromise=function(e){return!!e&&("object"==typeof e||typeof e==n)&&typeof obj.then==n},"undefined"!=typeof module&&module.exports&&(module.exports=o.isPromise)}();
13 changes: 13 additions & 0 deletions express.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const express = require('express');
const app = express();
const portNumber = 3000;
const sourceDir = 'src';

app.use(express.static('src'));
app.use(express.static('node_modules'));
app.use(express.static('__tests__'));

app.listen(portNumber, () => {
console.log(`Express web server started: http://localhost:${portNumber}`);
console.log(`Serving content from /${sourceDir}/`);
});
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://jestjs.io/docs/en/configuration
module.exports = {
verbose: true,
testRegex: [/\.spec.js/],
//preset: "jest-puppeteer",
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
}
};
39 changes: 23 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "next-is-promise",
"name": "@feizheng/next-is-promise",
"version": "1.0.0",
"description": "Test whether an object looks like a promisesA+ promise",
"description": "Test whether an object looks like a promises-a+ promise.",
"homepage": "https://github.com/afeiship/next-is-promise",
"author": {
"name": "afei",
Expand All @@ -10,27 +10,34 @@
"scripts": {
"build": "gulp",
"test": "jest",
"version": "gulp bump"
"start": "node ./express.js"
},
"main": "dist/next-is-promise.js",
"license": "MIT",
"devDependencies": {
"del": "^2.2.1",
"@feizheng/gulp-pkg-header": "^1.0.2",
"@feizheng/rake-git": "^1.2.1",
"del": "^5.1.0",
"express": "^4.17.1",
"gulp": "^4.0.2",
"gulp-bump": "^3.1.3",
"gulp-concat": "^2.6.0",
"gulp-header": "^2.0.7",
"gulp-load-plugins": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-size": "^2.1.0",
"gulp-uglify": "^2.1.2",
"jest": "^23.6.0",
"yargs": "^4.7.1",
"gulp-debug": "^4.0.0",
"gulp-header": "^2.0.9",
"gulp-ignore": "^3.0.0",
"gulp-load-plugins": "^2.0.2",
"gulp-rename": "^2.0.0",
"gulp-size": "^3.0.0",
"gulp-sourcemaps": "^2.6.5",
"gulp-uglify": "^3.0.2",
"jest": "^25.2.3",
"prettier": "^2.0.2",
"uglify-save-license": "^0.4.1",
"prettier": "^1.14.3",
"next-nice-comments": "github:afeiship/next-nice-comments"
"uglify-js": "3.7.2",
"yargs": "^15.3.1"
},
"dependencies": {
"next-js-core2": "github:afeiship/next-js-core2"
"@feizheng/next-js-core2": "^2.4.4"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
}
}
12 changes: 4 additions & 8 deletions src/next-is-promise.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
(function() {
(function () {
var global = global || this || window || Function('return this')();
var nx = global.nx || require('next-js-core2');
var nx = global.nx || require('@feizheng/next-js-core2');
var OBJ = 'object';
var FUNC = 'function';

nx.isPromise = function(inObj) {
return (
!!inObj &&
(typeof inObj === OBJ || typeof inObj === FUNC) &&
typeof obj.then === FUNC
);
nx.isPromise = function (inObj) {
return !!inObj && (typeof inObj === OBJ || typeof inObj === FUNC) && typeof obj.then === FUNC;
};

if (typeof module !== 'undefined' && module.exports) {
Expand Down
Loading

0 comments on commit 5d9699d

Please sign in to comment.