Skip to content

Commit

Permalink
Separate usemin API and this CLI module
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson Yeung committed Jan 22, 2017
1 parent 868fe49 commit e945926
Show file tree
Hide file tree
Showing 31 changed files with 55 additions and 697 deletions.
11 changes: 5 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# http://editorconfig.org
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[{package.json,bower.json,.travis.yml}]
indent_style = space
[{package.json,.travis.yml}]
indent_size = 2
indent_style = space

[*.md]
trim_trailing_whitespace = false
25 changes: 0 additions & 25 deletions .eslintrc.json

This file was deleted.

5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Nelson Yeung
Copyright (c) Nelson Yeung (nelsyeung.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
# usemin-cli [![Build Status](https://travis-ci.org/nelsyeung/usemin-cli.svg?branch=master)](https://travis-ci.org/nelsyeung/usemin-cli)
# usemin-cli [![Build Status](https://travis-ci.org/nelsyeung/usemin.svg?branch=master)](https://travis-ci.org/nelsyeung/usemin)

> CLI version of usemin. For _purists_, those who doesn't use build tools like [Grunt](https://github.com/yeoman/grunt-usemin) and [Gulp](https://github.com/zont/gulp-usemin), but just use NPM as their build tool.
## Getting started

To use this now, install with this command:
Install with NPM:
```
npm install usemin-cli
```

From GitHub
```
git clone https://github.com/nelsyeung/usemin-cli.git
cd usemin-cli
npm install
npm link
```
## API
[usemin](https://github.com/nelsyeung/usemin) - API for this module.

## Usage

Expand Down Expand Up @@ -108,13 +103,6 @@ module.exports = {
}
```

## What's being worked on
This is still under development. Any contributions will be much appreciated.

- Filerev
- Batch processing
- More and better tests

## License

[MIT license](http://opensource.org/licenses/MIT.php)
35 changes: 9 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,14 @@ var argv = require('yargs')
.demand(1)
.argv;

var fs = require('fs');
var getBlocks = require('./lib/getBlocks');
var getConfig = require('./lib/getConfig');
var processBlocks = require('./lib/processBlocks');
var getHTML = require('./lib/getHTML');
var html = require('usemin')(argv._[0], argv.dest, {
output: argv.o,
configFile: argv.c,
htmlmin: argv.htmlmin,
noprocess: argv.noprocess,
removeLivereload: argv.removeLivereload,
});

var filePath = argv._[0];
var content = fs.readFileSync(filePath).toString();
var blocks = getBlocks(argv._[0], content, argv.removeLivereload);
var config = getConfig(argv.c);
var process = (argv.noprocess === true) ? true : processBlocks(blocks, argv.dest, config);
var output = getHTML(content, blocks, argv.htmlmin, config);

if (process) {
if (argv.o) {
fs.writeFile(argv.o, output, function(err) {
if (err) {
throw Error(err);
}
});
}
else {
console.log(output); // eslint-disable-line no-console
}
}
else {
throw Error('Unexpected error.');
if (!argv.o) {
console.log(html);
}
104 changes: 0 additions & 104 deletions lib/getBlocks.js

This file was deleted.

38 changes: 0 additions & 38 deletions lib/getConfig.js

This file was deleted.

29 changes: 0 additions & 29 deletions lib/getHTML.js

This file was deleted.

48 changes: 0 additions & 48 deletions lib/processBlocks.js

This file was deleted.

Loading

0 comments on commit e945926

Please sign in to comment.