Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

micro-definition

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micro-definition - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

.bithoundrc

18

dist/micro-definition.js
/*!
* @ProjectName micro-definition
* @Version 0.0.4
* @Version 0.0.5
* @Author lixinliang(https://github.com/lixinliang)
* @Update 2016-11-30 2:05:23 pm
* @Update 2016-12-20 10:42:34 am
*/

@@ -51,3 +51,3 @@ /******/ (function(modules) { // webpackBootstrap

/* 0 */
/***/ function(module, exports) {
/***/ function(module, exports, __webpack_require__) {

@@ -66,3 +66,3 @@ 'use strict';

*/
var storage = microStorage('micro-definition');
var storage = microStorage(("micro-definition"));

@@ -78,3 +78,3 @@ var alias = {};

function throwError(message) {
throw new TypeError('micro-definition: ' + message);
throw new TypeError(("micro-definition") + ': ' + message);
}

@@ -106,4 +106,4 @@

if (result) {
var _dependency = result.dependency;
var content = result.content;
var _dependency = result.dependency,
content = result.content;

@@ -117,3 +117,3 @@ var _method = new Function('return ' + content)();

} else {
cache[id] = args[index] = new SyntaxError('micro-definition: "' + id + '" is not defined');
cache[id] = args[index] = new SyntaxError(("micro-definition") + ': "' + id + '" is not defined');
done();

@@ -227,3 +227,3 @@ callback();

Define.version = '0.0.4';
Define.version = ("0.0.5");
Define.storage = storage;

@@ -230,0 +230,0 @@

/*!
* @ProjectName micro-definition
* @Version 0.0.4
* @Version 0.0.5
* @Author lixinliang(https://github.com/lixinliang)
* @Update 2016-11-30 2:05:40 pm
* @Update 2016-12-20 10:42:41 am
*/
!function(n){function e(o){if(t[o])return t[o].exports;var r=t[o]={exports:{},id:o,loaded:!1};return n[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var t={};return e.m=n,e.c=t,e.p="",e(0)}([function(n,e){"use strict";function t(n){throw new TypeError("micro-definition: "+n)}function o(){}function r(n,e,t){var i=n.length;i?!function(){var d=function(){i--,i||t(e.apply(window,s))},l=function(n,e,t,o){if(n){var i=n.dependency,c=n.content,u=new Function("return "+c)();r(i,u,function(n){a[e]=s[t]=n,d(),o()})}else a[e]=s[t]=new SyntaxError('micro-definition: "'+e+'" is not defined'),d(),o()},s=[];n.forEach(function(n,e){if("function"==typeof u[n]&&(n=u[n].call(u)),a[n])s[e]=a[n],d();else{var t=c(n);t?l(t,n,e,o):u[n]?f[n]?f[n].push(function(){s[e]=a[n],d()}):!function(){f[n]=[];var t=document.createElement("script");t.src=u[n],t.onload=function(){document.head.removeChild(t);var o=c(n);l(o,n,e,function(){f[n].forEach(function(n){n()})})},document.head.appendChild(t)}():(s[e]=a[n]=void 0,d())}})}():t(e())}function i(n,e,i){arguments.length<2&&t("2 arguments required at least."),"string"!=typeof n?(i=e,e=n,n=null):n||t("Module id can not be empty."),e instanceof Array||(i=e,e=[]),"function"!=typeof i&&t("Module should be a function."),n?c(n,{dependency:e,timestamp:+new Date,content:i.toString()}):r(e,i,o)}var c=microStorage("micro-definition"),u={},a={},f={};i.alias=function(n){for(var e in n)u[e]=n[e]},i.version="0.0.4",i.storage=c,window.Define=i}]);
!function(n){function e(o){if(t[o])return t[o].exports;var i=t[o]={exports:{},id:o,loaded:!1};return n[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var t={};return e.m=n,e.c=t,e.p="",e(0)}([function(n,e,t){"use strict";function o(n){throw new TypeError("micro-definition: "+n)}function i(){}function r(n,e,t){var o=n.length;o?!function(){var c=function(){o--,o||t(e.apply(window,s))},l=function(n,e,t,o){if(n){var i=n.dependency,u=n.content,a=new Function("return "+u)();r(i,a,function(n){f[e]=s[t]=n,c(),o()})}else f[e]=s[t]=new SyntaxError('micro-definition: "'+e+'" is not defined'),c(),o()},s=[];n.forEach(function(n,e){if("function"==typeof a[n]&&(n=a[n].call(a)),f[n])s[e]=f[n],c();else{var t=u(n);t?l(t,n,e,i):a[n]?d[n]?d[n].push(function(){s[e]=f[n],c()}):!function(){d[n]=[];var t=document.createElement("script");t.src=a[n],t.onload=function(){document.head.removeChild(t);var o=u(n);l(o,n,e,function(){d[n].forEach(function(n){n()})})},document.head.appendChild(t)}():(s[e]=f[n]=void 0,c())}})}():t(e())}function c(n,e,t){arguments.length<2&&o("2 arguments required at least."),"string"!=typeof n?(t=e,e=n,n=null):n||o("Module id can not be empty."),e instanceof Array||(t=e,e=[]),"function"!=typeof t&&o("Module should be a function."),n?u(n,{dependency:e,timestamp:+new Date,content:t.toString()}):r(e,t,i)}var u=microStorage("micro-definition"),a={},f={},d={};c.alias=function(n){for(var e in n)a[e]=n[e]},c.version="0.0.5",c.storage=u,window.Define=c}]);
{
"name": "micro-definition",
"version": "0.0.4",
"version": "0.0.5",
"description": "(<2kb) A lite module loader and cache module in localStorage.",

@@ -31,3 +31,3 @@ "main": "dist/micro-definition.min.js",

"devDependencies": {
"autoprefixer-loader": "^3.2.0",
"autoprefixer": "^6.5.3",
"babel-core": "^6.9.1",

@@ -39,25 +39,33 @@ "babel-loader": "^6.2.4",

"babel-runtime": "^6.9.2",
"clean-webpack-plugin": "^0.1.14",
"coffee-loader": "^0.7.2",
"coffee-script": "^1.12.1",
"colors": "^1.1.2",
"css-loader": "^0.23.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"fs-extra": "^0.30.0",
"inline-source": "^5.0.0",
"inquirer": "^1.1.3",
"file-loader": "^0.9.0",
"fs-extra": "^1.0.0",
"html-inline-source-webpack-plugin": "^1.1.0",
"html-loader": "^0.4.4",
"html-webpack-plugin": "^2.24.1",
"inquirer": "^2.0.0",
"micro-storage": "0.0.9",
"minifycss-loader": "^0.2.0",
"moment": "~2.8.3",
"node-sass": "^3.7.0",
"sass-loader": "^3.2.0",
"moment": "^2.17.1",
"node-sass": "^3.13.1",
"postcss-loader": "^1.2.0",
"raw-loader": "^0.5.1",
"sass-loader": "^4.0.2",
"shelljs": "^0.7.0",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.4",
"url-loader": "^0.5.7",
"vue-hot-reload-api": "^1.3.2",
"vue-hot-reload-api": "^1.3.3",
"vue-html-loader": "^1.2.2",
"vue-loader": "^8.5.2",
"vue-loader": "^8.5.4",
"vue-style-loader": "^1.0.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
"vue-template-compiler": "^2.1.6",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
}
}
[![npm](https://img.shields.io/npm/l/micro-definition.svg?style=flat-square)](https://www.npmjs.org/package/micro-definition)
[![npm](https://img.shields.io/npm/v/micro-definition.svg?style=flat-square)](https://www.npmjs.org/package/micro-definition)
[![npm](https://img.shields.io/npm/dm/micro-definition.svg?style=flat-square)](https://www.npmjs.org/package/micro-definition)
[![bitHound Code](https://www.bithound.io/github/micro-app/micro-definition/badges/code.svg)](https://www.bithound.io/github/micro-app/micro-definition)

@@ -23,5 +24,6 @@ # micro-definition

#### Define a module
Define(String: id, Function: method);
```javascript
#### #Define a module
> Define( id : String, method : Function )
```js
Define('mod', function () {

@@ -33,5 +35,6 @@ // some code;

#### Define a module with dependencies
Define(String: id, Array: Dependency, Function: method);
```javascript
#### #Define a module with dependencies
> Define( id : String, dependency : Array, method : Function )
```js
Define('mod-a', ['mod-b', 'mod-c'], function ( b, c ) {

@@ -43,12 +46,15 @@ // some code;

#### Use modules
Define(Array: Dependency, Function: method);
````javascript
#### #Require modules
> Define( dependency : Array, callback : Function )
```js
Define(['jQuery', 'lodash'], function ( $, _ ) {
// some code;
});
````
```
#### Config of alias
````javascript
#### #Config of alias
> Define.alias( alias : Object )
```js
Define.alias({

@@ -58,13 +64,17 @@ 'mod-a' : 'a.js',

});
````
```
#### Show all defined modules
````javascript
#### #Show all defined modules
More `Define.storage` api see [micro-storage](https://github.com/micro-app/micro-storage).
```js
Define.storage.list();
````
```
#### Remove a defined module
````javascript
#### #Remove a defined module
More `Define.storage` api see [micro-storage](https://github.com/micro-app/micro-storage).
```js
Define.storage.remove('mod-a');
````
```

@@ -71,0 +81,0 @@ ## License

@@ -11,3 +11,3 @@ /**

*/
let storage = microStorage('@NAME');
let storage = microStorage(process.env.NAME);

@@ -23,3 +23,3 @@ let alias = {};

function throwError ( message ) {
throw new TypeError(`@NAME: ${ message }`);
throw new TypeError(`${ process.env.NAME }: ${ message }`);
}

@@ -58,3 +58,3 @@

} else {
cache[id] = args[index] = new SyntaxError(`@NAME: "${ id }" is not defined`);
cache[id] = args[index] = new SyntaxError(`${ process.env.NAME }: "${ id }" is not defined`);
done();

@@ -162,5 +162,5 @@ callback();

Define.version = '@VERSION';
Define.version = process.env.VERSION;
Define.storage = storage;
window.Define = Define;
'use strict';
let fs = require('fs');
let path = require('path');
let fse = require('fs-extra');
let moment = require('moment');
let webpack = require('webpack');
let Profile = require('./webpack.profile.js');
let ExtractText = require('extract-text-webpack-plugin');
let autoprefixer = require('autoprefixer');
let CopyWebpackPlugin = require('copy-webpack-plugin');
let HtmlWebpackPlugin = require('html-webpack-plugin');
let CleanWebpackPlugin = require('clean-webpack-plugin');
let ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
let HtmlInlineSourceWebpackPlugin = require('html-inline-source-webpack-plugin');
const alias = {};
const entry = require('./webpack.entry.json');
const packageJson = require('../package.json');
const alias = {};
const imageSize = 10240;
const sourcePath = path.join(__dirname, '../src');
const constant = {
NODE_ENV : 'production',
NAME : packageJson.name,
VERSION : packageJson.version,
};
const banner =

@@ -19,11 +33,30 @@ `@ProjectName ${ packageJson.name }

const imageSize = 10240;
process.argv.forEach(( param ) => {
if (/^--/.test(param)) {
let temp = param.slice(2).split('=');
let key = temp[0];
let value = temp[1] || true;
process.argv[key] = value;
}
});
module.exports = {
let config = {
entry,
output : {
path : './dist/js/',
filename : '[name].js',
},
extensions : ['.vue', '.js', '.json', '.scss', '.html'],
output : (() => {
if (process.argv.build == 'js') {
return {
path : './dist/',
filename : `[name]${ process.argv.uglify ? '.min' : '' }.js`,
library : process.argv.library,
libraryTarget : process.argv.libraryTarget,
};
} else {
return {
path : './dist/',
filename : 'js/[name].js',
publicPath : '',
};
}
})(),
extensions : ['.vue', '.js', '.coffee', '.json', '.scss'],
resolve : {

@@ -39,16 +72,12 @@ alias,

{
test : /\.html$/,
loader : 'vue-html',
},
{
test : /\.(png|jpg|gif|svg)$/,
loader : `url?limit=${ imageSize }&name=../img/[name].[ext]?[hash]`,
loader : `url?limit=${ imageSize }&name=${ process.argv.build == 'js' ? '../' : '' }img/[name].[ext]?[hash]`,
},
{
test : /\.css$/,
loader : ExtractText.extract('style', 'css'),
loader : process.argv.build == 'js' ? 'css!postcss' : ExtractTextWebpackPlugin.extract('style', 'css!postcss'),
},
{
test : /\.scss$/,
loader : ExtractText.extract('style', 'css?localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!sass'),
loader : process.argv.build == 'js' ? 'css!postcss!sass' : ExtractTextWebpackPlugin.extract('style', 'css!postcss!sass'),
},

@@ -65,20 +94,22 @@ {

},
{
test : /\.coffee/,
loader : 'coffee',
},
{
test : /\.(coffee\.md|litcoffee)$/,
loader : 'coffee?literate',
},
],
},
plugins : [
new ExtractText('../css/[name].css'),
new webpack.Profile(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV : '"production"',
},
}),
new webpack.optimize.UglifyJsPlugin({
compress : {
warnings : false,
},
output : {
comments : false,
},
}),
new webpack.DefinePlugin((() => {
let result = {};
Object.keys(constant).forEach(( key ) => {
result[key] = JSON.stringify(constant[key]);
});
return {
'process.env' : result,
};
})()),
new webpack.BannerPlugin(banner),

@@ -88,33 +119,82 @@ ],

loaders : {
sass : ExtractText.extract('style', 'css!autoprefixer?browsers=last 2 version!sass?indentedSyntax'),
scss : ExtractText.extract('style', 'css!autoprefixer?browsers=last 2 version!sass'),
}
sass : ExtractTextWebpackPlugin.extract('style', 'css!postcss!sass'),
scss : ExtractTextWebpackPlugin.extract('style', 'css!postcss!sass'),
},
},
postcss () {
return [autoprefixer({ browsers : ['last 2 versions'] })];
},
};
process.argv.forEach(( param ) => {
if (/^--/.test(param)) {
let temp = param.slice(2).split('=');
let key = temp[0];
let value = temp[1] || true;
process.argv[key] = value;
}
});
let plugins = config.plugins;
if (process.argv.build == 'js') {
if (process.argv.uglify) {
module.exports.plugins.shift();
plugins.unshift(new webpack.optimize.UglifyJsPlugin({
compress : {
warnings : false,
},
output : {
comments : false,
},
}));
} else {
module.exports.plugins.splice(3, 1);
module.exports.plugins.shift();
plugins.unshift(new CleanWebpackPlugin(['dist'], {
root : path.join(__dirname, '..'),
}));
}
let loaders = module.exports.module.loaders;
loaders[3].loaders = ['css', 'autoprefixer'];
loaders[4].loaders = ['css', 'autoprefixer', 'sass'];
loaders[3].loader = loaders[4].loader = void 0;
module.exports.output = {
path : './dist/',
filename : `[name]${ process.argv.uglify ? '.min' : '' }.js`,
library : process.argv.library,
libraryTarget : process.argv.libraryTarget,
};
} else {
plugins.unshift(new webpack.optimize.UglifyJsPlugin({
compress : {
warnings : false,
},
output : {
comments : false,
},
}));
plugins.unshift(new CopyWebpackPlugin((() => {
let result = [];
fs.readdirSync(sourcePath).forEach(( filename ) => {
let file = path.join(sourcePath, filename);
if (filename[0] === '.') {
return;
}
let stats = fs.statSync(file);
if (stats.isDirectory()) {
if (filename == 'entry') {
return;
}
}
if (stats.isFile()) {
if (path.extname(file) == '.html') {
return;
}
if (path.extname(file) == '.appcache') {
return;
}
}
result.push({
form : file,
to : filename,
});
});
return result;
})()));
plugins.unshift(new CleanWebpackPlugin(['dist'], {
root : path.join(__dirname, '..'),
}));
plugins.push(new ExtractTextWebpackPlugin('css/[name].css'));
fs.readdirSync(sourcePath).forEach(( filename ) => {
let template = path.join(sourcePath, filename);
if (/\.(appcache|html)$/.test(filename)) {
plugins.push(new HtmlWebpackPlugin({
minify : false,
inject : false,
filename,
template,
}));
}
});
plugins.push(new HtmlInlineSourceWebpackPlugin());
}
module.exports = config;

@@ -5,10 +5,16 @@ 'use strict';

let webpack = require('webpack');
let ExtractText = require('extract-text-webpack-plugin');
let autoprefixer = require('autoprefixer');
let ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const alias = {};
const entry = require('./webpack.entry.json');
const packageJson = require('../package.json');
const alias = {};
const imageSize = 10240;
const constant = {
NAME : packageJson.name,
VERSION : packageJson.version,
};
module.exports = {
let config = {
devtool : '#source-map',

@@ -20,3 +26,3 @@ entry,

},
extensions : ['.vue', '.js', '.json', '.scss', '.html'],
extensions : ['.vue', '.js', '.coffee', '.json', '.scss'],
resolve : {

@@ -33,3 +39,3 @@ alias,

test : /\.html$/,
loader : 'vue-html',
loader : 'raw',
},

@@ -42,7 +48,7 @@ {

test : /\.css$/,
loader : ExtractText.extract('style', 'css'),
loader : ExtractTextWebpackPlugin.extract('style', 'css!postcss'),
},
{
test : /\.scss$/,
loader : ExtractText.extract('style', 'css?localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!sass'),
loader : ExtractTextWebpackPlugin.extract('style', 'css!postcss!sass'),
},

@@ -59,13 +65,34 @@ {

},
{
test : /\.coffee/,
loader : 'coffee',
},
{
test : /\.(coffee\.md|litcoffee)$/,
loader : 'coffee?literate',
},
],
},
plugins : [
new ExtractText('css/[name].css'),
new ExtractTextWebpackPlugin('css/[name].css'),
new webpack.DefinePlugin((() => {
Object.keys(constant).forEach(( key ) => {
constant[key] = JSON.stringify(constant[key]);
});
return {
'process.env' : constant,
};
})()),
],
vue : {
loaders : {
sass : ExtractText.extract('style', 'css!autoprefixer?browsers=last 2 version!sass?indentedSyntax'),
scss : ExtractText.extract('style', 'css!autoprefixer?browsers=last 2 version!sass'),
sass : ExtractTextWebpackPlugin.extract('style', 'css!postcss!sass'),
scss : ExtractTextWebpackPlugin.extract('style', 'css!postcss!sass'),
},
},
postcss () {
return [autoprefixer({ browsers : ['last 2 versions'] })];
},
};
module.exports = config;

@@ -8,33 +8,35 @@ 'use strict';

let colors = require('colors');
let inline = require('inline-source').sync;
let inquirer = require('inquirer');
const port = 8080;
const task = process.argv[2].substring(1);
const buildjs = process.argv[3] == 'js';
const sourcePath = path.join(__dirname, '../src');
const outputPath = path.join(__dirname, '../dist');
let cmd;
let start = () => {
let task = process.argv[2].substring(1);
if (task == 'dev') {
cmd = `webpack-dev-server --inline --quiet --devtool eval --progress --colors --content-base ./src/ --hot --config ./webpack/webpack.dev.js --host 0.0.0.0 --port ${ port }`;
step3().then(step4).catch(( err ) => {
if (/listen EADDRINUSE/.test(err.toString())) {
console.log(`\n${ port } is aleary in use. Ctrl+C to leave or input a PID to kill:`.green);
cmd = `lsof -i tcp:${ port }`;
step4().then(step6).then(( pid ) => cmd = `kill ${ pid }`).then(step4).catch(( err ) => {
console.log(err.toString().red);
}).then(start);
} else {
function reboot ( err ) {
if (/listen EADDRINUSE/.test(err.toString())) {
console.log(`\n${ port } is aleary in use. Ctrl+C to leave or input a PID to kill:`.green);
Promise.resolve(`lsof -i tcp:${ port }`).then(step2).then(step3).then(( pid ) => {
return `kill ${ pid }`;
}).then(step2).catch(( err ) => {
console.log(err.toString().red);
}
});
}).then(start);
} else {
console.log(err.toString().red);
}
}
if (task == 'dev') {
step1().then(() => {
return `webpack-dev-server --inline --quiet --devtool eval --progress --colors --content-base ./src/ --hot --config ./webpack/webpack.dev.js --host 0.0.0.0 --port ${ port }`;
}).then(step2).catch(reboot);
}
if (task == 'build') {
cmd = 'webpack --progress --colors --config ./webpack/webpack.build.js';
if (process.argv[3] && process.argv[3] == 'js') {
step3().then(step7).then(step8).then(( option ) => cmd += option).then(step1).then(step4).then(() => {
cmd += ' --uglify';
}).then(step4).then(() => {
if (buildjs) {
step1().then(step4).then(step5).then(( option ) => {
return `webpack --progress --colors --config ./webpack/webpack.build.js${ option }`;
}).then(step2).then(( cmd ) => {
return `${ cmd } --uglify`;
}).then(step2).then(() => {
console.log('build complete!'.green);

@@ -45,3 +47,5 @@ }).catch((err) => {

} else {
step1().then(step2).then(step3).then(step4).then(step5).then(() => {
step1().then(() => {
return `webpack --progress --colors --config ./webpack/webpack.build.js`;
}).then(step2).then(() => {
console.log('build complete!'.green);

@@ -56,44 +60,6 @@ }).catch(( err ) => {

/**
* [step1] fse.remove -- Remove old files
* @return {Promise} remove_success
* [step1] fse.outputJson -- Create `webpack.entry.json` dynamically
* @return {Promise} create_entry_success
*/
let step1 = () => new Promise(( resolve, reject ) => {
fse.remove(path.join(outputPath, '*'), ( err ) => {
if (err) {
reject(err);
return;
}
resolve();
});
});
/**
* [step2] fse.copySync -- Copy files like `html` or `images`
* @return {Promise} copy_success
*/
let step2 = () => new Promise(( resolve, reject ) => {
fs.readdir(sourcePath, ( err, files ) => {
if (err) {
reject(err);
return;
}
files.forEach(( filename ) => {
let file = path.join(sourcePath, filename);
if (filename[0] === '.') {
return;
}
if (fs.statSync(file).isDirectory() && filename == 'entry') {
return;
}
fse.copySync(file, path.join(outputPath, filename));
});
resolve();
});
});
/**
* [step3] fse.outputJson -- Create `webpack.entry.json` dynamically
* @return {Promise} create_entry_success
*/
let step3 = () => new Promise(( resolve, reject ) => {
let entry = {};

@@ -123,9 +89,10 @@ let entryPath = path.join(sourcePath, 'entry');

/**
* [step4] shell.exec -- Exec command
* [step2] shell.exec -- Exec command
* @param {String} cmd command
* @return {Promise} exec_command_success
*/
let step4 = () => new Promise(( resolve, reject ) => {
let step2 = ( cmd ) => new Promise(( resolve, reject ) => {
let result = shell.exec(cmd);
if (result.code === 0) {
resolve();
resolve(cmd);
} else {

@@ -137,51 +104,6 @@ reject(result.stderr);

/**
* [step5] inline -- According to `inline` attribute and replace the code of file
* @return {Promise} inline_success
*/
let step5 = () => new Promise(( resolve, reject ) => {
fs.readdir(outputPath, ( err, files ) => {
if (err) {
reject(err);
return;
};
files.forEach(( filename ) => {
let file = path.join(outputPath, filename);
if (fs.statSync(file).isFile() && path.extname(file) == '.html') {
let html = inline(file, {
compress : false,
rootpath : path.resolve('dist'),
handlers ( source, context ) {
if (source && source.fileContent && !source.content) {
if (source.extension == 'css') {
source.tag = 'style';
source.content = source.fileContent.replace(/url\(.*?\)/g, function ( match ) {
let url = match.substring(0, match.length - 1).substring(4);
if (/^http(s?):\/\/|^data:image/.test(url)) {
return match;
} else {
if (url.indexOf('?')) {
url = url.split('?')[0];
}
return `url(${ path.join('dist', url) })`;
}
});
}
if (source.extension == 'js') {
source.content = source.fileContent.trim();
}
}
},
});
fs.writeFileSync(file, html);
}
});
resolve();
});
});
/**
* [step6] inquirer.prompt -- Get PID
* [step3] inquirer.prompt -- Get PID
* @return {Promise} get_pid_success
*/
let step6 = () => new Promise(( resolve, reject ) => {
let step3 = () => new Promise(( resolve, reject ) => {
inquirer.prompt([{

@@ -199,6 +121,7 @@ type : 'input',

/**
* [step7] inquirer.prompt -- Get js file
* [step4] inquirer.prompt -- Get js file
* @param {JSON} entry entry
* @return {Promise} get_js_success
*/
let step7 = ( entry ) => new Promise(( resolve, reject ) => {
let step4 = ( entry ) => new Promise(( resolve, reject ) => {
let choices = Object.keys(entry);

@@ -234,6 +157,7 @@ if (choices.length) {

/**
* [step8] fs.readFile -- Get js webpack config
* [step5] fs.readFile -- Get js webpack config
* @param {String} filepath filepath
* @return {Promise} get_config_success
*/
let step8 = ( filepath ) => new Promise(( resolve, reject ) => {
let step5 = ( filepath ) => new Promise(( resolve, reject ) => {
fs.readFile(filepath, (err, buffer) => {

@@ -240,0 +164,0 @@ if (err) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc