Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
1000ch committed Sep 21, 2016
1 parent add5c64 commit 9f77fe5
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,6 @@ import postcss from 'postcss';
import scss from 'postcss-scss';
import stylefmt from 'stylefmt';

function execute() {
const editor = atom.workspace.getActiveTextEditor();

if (!editor) {
return;
}

const position = editor.getCursorBufferPosition();
const grammer = editor.getGrammar().name.toLowerCase();
const paths = atom.project.getPaths();
const text = editor.getText();
const options = grammer === 'scss' ? {
syntax : scss
} : {};

postcss([
stylefmt({
config: `${paths[0]}/.stylelintrc`
})
]).process(text, options)
.then(result => {
editor.setText(result.css);
editor.setCursorBufferPosition(position);
});
}

let subscriptions;
let editorObserver;
let formatOnSave;
Expand Down Expand Up @@ -59,3 +33,29 @@ export function deactivate() {
subscriptions.dispose();
editorObserver.dispose();
}

function execute() {
const editor = atom.workspace.getActiveTextEditor();

if (!editor) {
return;
}

const position = editor.getCursorBufferPosition();
const grammer = editor.getGrammar().name.toLowerCase();
const paths = atom.project.getPaths();
const text = editor.getText();
const options = grammer === 'scss' ? {
syntax : scss
} : {};

postcss([
stylefmt({
config: `${paths[0]}/.stylelintrc`
})
]).process(text, options)
.then(result => {
editor.setText(result.css);
editor.setCursorBufferPosition(position);
});
}

0 comments on commit 9f77fe5

Please sign in to comment.